I am fairly new to asp.net, I am trying to connect to a sql (mysql prefferably) database, it must be using C#. I have been searching all of yesterday and today, I cant figure out how. Could someone help me here (if this has been asked, please point me to a topic)

dude u need to create OdbcConnection.

using this object u can connect to any type of db such as (mssql, oracle, mysql, excel...)

dude i amnot sure abt the stability in using mysql with .net.


It solves what to give it, but not on what to put it in. what use is a string with no command?

Does anyone know the answer to my question? it cant be that hard.

string connectString = @"Data Source=YOURPC\SQLEXPRESS;Initial Catalog=databasename;Integrated Security=True";
SqlConnection con = new SqlConnection(connectString);
string thesql= "select * from product where type_id=" + thistype + " and part_id="+thispart;
SqlCommand cmd = new SqlCommand(thesql, con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
  string order = reader[2].ToString();
  Response.Write("Order is " + order+ "<br>");

Edited 5 Years Ago by __avd: Added [code] tags.

This article has been dead for over six months. Start a new discussion instead.