marinajogy
December 31st, 2008, 11:22 PM
Hello,
In my vb 2005, form one combobox and a datagrid view
datagridview filled via dataset and sqldataadapter - declared class objects
when an item in the combobox selected, some subitems corresponding to the combobox selecteditem is displayed in the gridview.
ie., when a new item selected clear the grid and fill the grid from the new record set.
see the code below
Dim groupId As Int32
cmdobj.CommandType = CommandType.StoredProcedure
cmdobj.CommandText = "select_groupId_on_groupName" : cmdR.Parameters.Clear()
cmdobj.Parameters.Add("@GroupName", SqlDbType.VarChar, 20, "groupName").Value = GroupName.Text
groupId = cmdR.ExecuteScalar() : cmdR.Parameters.Clear()
cmdobj.CommandText = "select_items_onGroupId" : cmdR.Parameters.Clear()
cmdobj.Parameters.Add("@GroupId", SqlDbType.SmallInt, 0, "groupId").Value = groupId
adpobj.SelectCommand = cmdobj : adpobj.Fill(dsobj)
DataGridView1.DataSource = String.Empty : DataGridView1.DataSource = dsobj.Tables(0)
unfortunately this code not works as I intended, gird not get cleared,
any help,thanks
In my vb 2005, form one combobox and a datagrid view
datagridview filled via dataset and sqldataadapter - declared class objects
when an item in the combobox selected, some subitems corresponding to the combobox selecteditem is displayed in the gridview.
ie., when a new item selected clear the grid and fill the grid from the new record set.
see the code below
Dim groupId As Int32
cmdobj.CommandType = CommandType.StoredProcedure
cmdobj.CommandText = "select_groupId_on_groupName" : cmdR.Parameters.Clear()
cmdobj.Parameters.Add("@GroupName", SqlDbType.VarChar, 20, "groupName").Value = GroupName.Text
groupId = cmdR.ExecuteScalar() : cmdR.Parameters.Clear()
cmdobj.CommandText = "select_items_onGroupId" : cmdR.Parameters.Clear()
cmdobj.Parameters.Add("@GroupId", SqlDbType.SmallInt, 0, "groupId").Value = groupId
adpobj.SelectCommand = cmdobj : adpobj.Fill(dsobj)
DataGridView1.DataSource = String.Empty : DataGridView1.DataSource = dsobj.Tables(0)
unfortunately this code not works as I intended, gird not get cleared,
any help,thanks