know its a trivial thing but some how I cannot sort it out.
I use the following code for deleting a record in ADO.NET backend SQL SERVER
I populate the combo box first by the following
Then I wrote the below code in cboDSEARCH Text_changed event
The data gets deleted. But eg. if i deleted record no 2 and I scroll the combobox upwards then i get the error
"invalid attempt to read when no data is present"
I want to know how to refresh the data reader.
In VB6.0 I used to write data1.refresh
what is its equivalent in ado.net
Thanks
cmr
I use the following code for deleting a record in ADO.NET backend SQL SERVER
I populate the combo box first by the following
VB.NET:
MyCon.Open()
MySelect = New SqlCommand("select pid from CustomerDetails", MyCon)
MyDr = MySelect.ExecuteReader
cboDSEARCH.Items.Clear()
While MyDr.Read
cboDSEARCH.Items.Add(MyDr("pid"))
End While
MyCon.Close()
VB.NET:
MyCon.Open()
MySelect = New SqlCommand("select name from CustomerDetails where pid=" & Val(cboDSEARCH.Text), MyCon)
MyDr = MySelect.ExecuteReader
MyDr.Read()
txtDNAME.Text = MyDr("name")
MyDr.Close()
Dim A As Integer
Dim Msg, Style, Title, Response, MyString
Msg = "Do you want to Delete ?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton1 ' Define buttons.
Title = "Bank Details" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
MyClean = New SqlCommand("delete from CustomerDetails where pid=" & Val(cboDSEARCH.Text), MyCon)
MyDel = MyClean.ExecuteReader
MyDel.Read()
MsgBox("deleted")
Else 'Perform some action.
MsgBox("Details not deleted")
End If
MyCon.Close()
"invalid attempt to read when no data is present"
I want to know how to refresh the data reader.
In VB6.0 I used to write data1.refresh
what is its equivalent in ado.net
Thanks
cmr
Last edited by a moderator: