What are the steps in connecting to database ?

Answer Posted / khalid

// Declare Namespace as ur Lang...
In c#

Using System.Data.SqlClient;

//connection
//If u provide uname & passwd to ur Database then this state //is true
SqlConnection con = new
SqlConnection("server=localhost;database=urDB_Name;uid=sa;pwd=;");
//else
SqlConnection con = new
SqlConnection("server=localhost;database=urDB_Name;");

con.Open();
if(con!=null)
msgbox("Connection sucessfully Done!");
else
msgbox("Sorry!Connection sucessfully is not Done!");

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which object is used to add relationship between two Datatables?

573


Is entity framework better than ado.net?

481


What are the steps you will take to improve performance?

463


oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?

1930


How to pass multiple tables in datasets simultaneously?

569






What provider ado.net use by default? Explain the role of data provider in ado.net? What is the role of data provider in ado.net?

536


Which control of the BindingNavigator returns the current position within the data source?

729


What is the difference between ado.net and entity framework?

506


What is DataRowCollection?

621


What you mean by filtering of data?

537


What is data relation in ado.net?

517


Explain how do you connect to sql server database without using sqlclient?

478


How does ado.net work?

492


What are the several execute methods of ado.net?

500


Define partial class?

512