Here is the Code I am working with that another member posted to help me out but it is throwing an Error that I just cannot figure out.
Thank You for the help!
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: Column 'ToyInfo' does not belong to table MyDataBinding.
string ToyInfo = drv.Row["ToyInfo"].ToString();
Below is the entire block of code:
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataGridRow dgr = sender as DataGridRow;
DataRowView drv = dgr.DataContext as DataRowView;
string toyId = drv.Row["ToyId"].ToString();
conConnect = new SqlConnection("Data Source=GERRY;Initial Catalog=toyDB;Integrated Security=True");
SqlCommand command = new SqlCommand("SELECT * FROM ToyInfo WHERE ToyId=@ToyId");
command.Connection = conConnect;
command.Parameters.AddWithValue("@ToyId", toyId);
conConnect.Open();
dAdapter = new SqlDataAdapter(command);
DS = new DataSet();
dAdapter.Fill(DS, "MyDataBinding");
datagrid2.ItemsSource = DS.Tables[0].AsDataView();
dAdapter.Dispose();
conConnect.Close();
}
No comments:
Post a Comment