Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako da dodam where u select komandu

[es] :: .NET :: .NET Desktop razvoj :: Kako da dodam where u select komandu

[ Pregleda: 1534 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

boguda
Belgrade

Član broj: 310711
Poruke: 100
*.dynamic.isp.telekom.rs.



+2 Profil

icon Kako da dodam where u select komandu31.05.2013. u 17:36 - pre 132 meseci
napisao sam komandu select
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Baza1.mdf;Integrated Security=True;User Instance=True");
SqlDataAdapter dap = new SqlDataAdapter("select * from uplate", con);
DataSet ds = new DataSet();
dap.Fill(ds);
dataGridView2.DataSource = ds.Tables[0];
e sada bi dodao where mesecID=@mesecID
a vrednos mesec ID je u combobox-u

kad radim sa sqlcomand znam da napisem upit nps sqlcommand con=new sqlcommand(...
com.parametars.addwithvalue("@mesecID",combobox.selectedvalue);

ali ne znam kako da dodelim vrednos parametru kad radim sa sqldataadapter_om
bez blama
 
Odgovor na temu

Dusan Kondic
Programer
ZR "Parametar" Ljubovija
Ljubovija

Član broj: 49961
Poruke: 225
109.121.58.*

Sajt: www.drinacoding.com


+14 Profil

icon Re: Kako da dodam where u select komandu31.05.2013. u 17:44 - pre 132 meseci
Nešto kao:
Code:

SqlDataAdapter dap = new SqlDataAdapter("select * from uplate where mesecID = " + combobox.selectedvalue.ToString(), con);
 
Odgovor na temu

boguda
Belgrade

Član broj: 310711
Poruke: 100
*.dynamic.isp.telekom.rs.



+2 Profil

icon Re: Kako da dodam where u select komandu01.06.2013. u 15:04 - pre 132 meseci
uspeo sam i ovako ne znam da li te pravilno ali radi

private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Baza1.mdf;Integrated Security=True;User Instance=True");
SqlDataAdapter dap = new SqlDataAdapter("select * from uplate where racunID=@racunID", con);

dap.SelectCommand.Parameters.AddWithValue("@racunID",comboBox4.SelectedValue); OVO SAM DODAO
DataSet ds = new DataSet();
dap.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
bez blama
 
Odgovor na temu

[es] :: .NET :: .NET Desktop razvoj :: Kako da dodam where u select komandu

[ Pregleda: 1534 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.