|
-
Aug 14th, 2007, 05:01 AM
#1
Thread Starter
New Member
db connections
how to create a db connection with sqlserver with c#.net and what is the code
-
Aug 14th, 2007, 07:04 AM
#2
Re: db connections
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.
-
Aug 14th, 2007, 07:13 AM
#3
-
Aug 15th, 2007, 05:09 AM
#4
Addicted Member
Re: db connections
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");
-
Aug 15th, 2007, 05:17 AM
#5
Re: db connections
 Originally Posted by carstenht
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.
-
Aug 15th, 2007, 05:27 AM
#6
Addicted Member
Re: db connections
didnt see that, but oh well. With sqlserver its even easier - stumbled upon a code sample from msdn the other day. google it
-
Aug 17th, 2007, 12:30 AM
#7
PowerPoster
Re: db connections
 Originally Posted by varun
how to create a db connection with sqlserver with c#.net and what is the code
Why wold anyone even want to help someone with absolutely no manners and who is so demanding?
Not even a HI or THANKS??
You might as well have ended it with, "NOW BITCHES!"
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|