I need help with embedded sql and c#. How does C# implement embedded sql?
Embedded sql?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Suthish NairRank #93 · 22.6K pointsPosted Dec 11, 2012, 10:15 AM EST
String connString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString();
String sSQL = "select * from dbo.Categories ";
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand cmd = new SqlCommand())
{
conn.Open();
cmd.CommandText = sSQL;
cmd.Connection = conn;
using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
{
using (DataSet result = new DataSet())
{
result.Load(dr);
}
}
}
}