Hello Sir,
Im getting error :
Must declare the scalar variable "@name".
In below code
String query = "SELECT staff.*, holidays.date FROM abc_staff as staff INNER JOIN holidays ON staff.from_date=holidays.date where" +
" staff.staff_name = @name and staff.from_date = @from_date and staff.to_date = @to_date";
SqlCommand cmd12 = new SqlCommand();
cmd12.Parameters.AddWithValue("@name", DropDownList1.SelectedItem.Text);
cmd12.Parameters.AddWithValue("@from_date", Convert.ToDateTime(txt_fromdate.Text));
cmd12.Parameters.AddWithValue("@to_date", Convert.ToDateTime(txt_todate.Text));
cmd12.CommandType = CommandType.Text;
cmd12.CommandText = query;
cmd12.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
da.Fill(dt);
Please help me
Thanks