0

I have this commad that where id=333 how can I attach a string that will automatically put 333 with a sql query

string constr = ConfigurationManager.ConnectionStrings["PTS_Metcom"].ToString();
                
// SqlConnection cn = new SqlConnection(@"data source=DESKTOP-6DF0CN3\SQLEXPRESS; Database=EmployeeDatabase; integrated security = true");
SqlConnection cn = new SqlConnection(constr);
SqlCommand isim = new SqlCommand("select FIRMA_ADI from ARAC_SAHIPLERI where ID=333", cn);
SqlCommand kota = new SqlCommand("select AYNI_ANDA_KAPASITE from ARAC_SAHIPLERI where ID=333", cn);
SqlCommand iceride = new SqlCommand("select AYNI_ANDA_KAPASITE from ARAC_SAHIPLERI where ID=333", cn);
SqlCommand kalan = new SqlCommand("select AYNI_ANDA_KAPASITE from ARAC_SAHIPLERI where ID=333", cn);
cn.Open();

SqlDataReader rdr111 = isim.ExecuteReader();
while (rdr111.Read())
{
   // Print employee details  
   ViewBag.isim = (rdr111[0]);
   // Console.WriteLine(rdr[0]);
}

rdr111.Close();
2
  • a) Read up on Dapper Commented Jan 15 at 8:27
  • b) Read up on SqlParameter Commented Jan 15 at 8:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.