how to create a db connection with sqlserver with c#.net and what is the code
Printable View
how to create a db connection with sqlserver with c#.net and what is the code
Firstly, this is the VB.NET forum, not the C# forum. Secondly, exactly how you connect to the database depends on your circumstances. You can create an SqlConnection in code or in the designer, or you can use the Data Source wizard to have the IDE generate a typed DataSet for you, which encapsualtes all the connections and SQL code.
Moved to C# section
Hi
First of all, you need to install the MySQL Connector for .NET(found on mysql.com). Then you need to add this as a reference to your project.
Now, to initiate a connection, you could do this:
Code:MySqlConnection myConnection;
MySqlDataAdapter myDataAdapter;
DataSet myDataSet;
String strSQL; // Query string
// initiate connection
myConnection = new MySqlConnection("server=server-name; user id=use; password=pasword; database=database-schema; pooling=false;");
// Now a sample query:
strSQL = "SELECT * FROM Something;";
myDataAdapter = new MySqlDataAdapter(strSQL, myConnection);
myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Something");
I don't think the MySQL ADO.NET provider is going to be much help in connection to SQL Server.Quote:
Originally Posted by carstenht
didnt see that, but oh well. With sqlserver its even easier - stumbled upon a code sample from msdn the other day. google it
Why wold anyone even want to help someone with absolutely no manners and who is so demanding?Quote:
Originally Posted by varun
Not even a HI or THANKS??
You might as well have ended it with, "NOW BITCHES!"