SQL Query With Parameter

To Query on Sql Server With Parameter- The Best Way
string sqlCon = ConfigurationManager.ConnectionStrings["AdventureWorksConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(sqlCon);
SqlCommand com = new SqlCommand("select * from Test1 where ID=@ID", con);
com.Parameters.Add("@ID", SqlDbType.Int).Value = 6;
SqlDataAdapter adp = new SqlDataAdapter(com);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

Comments

Popular posts from this blog

To Move items from one ListBox to another Listbox

Receive Json Web response in C#