i've a problem in my sql request as you here :
string
SQL_str;System.
DateTime now = System.DateTime.Now; DateTime d = now.AddDays(2);SQL_str =
"SELECT DemandID, FirstName, LastName, SDate, EDate FROM dbo.RentDemand where SDate = @d"; String Con = @"Data Source=USER\SQLEXPRESS;Initial Catalog=RentDB;Integrated Security=True"; SqlDataAdapter dataAdapter = new SqlDataAdapter(mySQL, Con); SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter); DataTable table = new DataTable();table.Locale = System.Globalization.
CultureInfo.InvariantCulture;dataAdapter.Fill(table);
rentDemandBindingSource.DataSource = table;
dataGridView2.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);dataGridView2.ReadOnly = true;dataGridView2.DataSource = rentDemandBindingSource;
it doesnt work ,can anyone show me what's the problemm ?
AlexPosted Oct 5, 2008, 7:10 PM
adapter.SelectCommand.Parameters.AddWithValue("@d",d);
That adds your C# d variable to your sql @d variable. (Sort of like if you were working with a stored proc).