private void button3_Click(object sender, EventArgs e)
{
string ssr;
SqlConnection scr = new SqlConnection(@"Data Source=USER-PC\MSSQL;Initial Catalog=Highscore;Integrated Security=True");
scr.Open();
ssr = "Select Nume,Scor,DataInitiala,DataRecenta FROM Users where DataInitiala between @Param and @Param1 ";
SqlCommand cmd2 = new SqlCommand(ssr, scr);
cmd2.Parameters.AddWithValue("@Param", from.Text);
cmd2.Parameters.AddWithValue("@Param1", to.Text);
SqlDataAdapter adapter1 = new SqlDataAdapter(ssr, scr);
DataSet ds1 = new DataSet();
adapter1.Fill(ds1);
dataGridView1.DataSource = ds1.Tables[0];
dataGridView1.Refresh();
}
What am I missing here?I have the error Must Declare scalar variable @Param
from.Text's value? - Tzah MamaBETWEEN. Also, you should be converting the parameters to the proper type before inclusion in the query anyways, don't just assume the text values are correct. This doesn't necessarily solve your problem, though... - Clockwork-Muse