Click here to Skip to main content
16,018,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

VB
Dim dv As New DataView(_DataSet.Tables(0))
            dv.RowStateFilter = DataViewRowState.Deleted
       For _irow As Long = 0 To dv.Table.Rows.Count - 1
                      If Not IsDBNull(dv!serial) Then
               Dim strconnection As String = "Data Source=EASMAR-PC;Initial Catalog=Database Connection;Integrated Security=True;"
               Dim _cn As SqlConnection = New SqlConnection(strconnection)
               _cn.Open()
               Dim cmd As New SqlCommand
               cmd.CommandText = "Delete from tblCustomer where serial= " & txtSerial.Text
           End If
       Next


What am i missing?

I am getting this error:

VB
Conversion from string "serial" to type integer is not valid.


On this line:
VB
If Not IsDBNull(dv!serial) Then
Posted
Updated 2-Jan-14 0:35am
v3
Comments
thatraja 2-Jan-14 4:05am    
In which line the error occurs? Always mention this
Glagace_7763 2-Jan-14 14:59pm    
Not positive what you are trying to accomplish but it seems you are passing the entire column to the IsDBNull function, even though you believe you are looping through the dataview. dv!serial is not a specific row in the dataview. Could provide more information on what you are trying accomplished.

This thread may provide a better way to perform the task you are attempting.

http://www.vbforums.com/showthread.php?469872-Retrieving-and-Saving-Data-in-Databases
[no name] 3-Jan-14 2:49am    
After i delete, insert, update into my dataset;I am trying to loop through the rows in my dataview, check the row state, if it's deleted(respectevely updated, inserted) i do the delete(respectively update, insert) in the database.
I know that the dataadapter does that for me. But i have to do it this way.
Any help would be appreciated
G-code101 5-Feb-14 7:42am    
Try passing the row instead of the string value of the column name

If Not IsDBNull(dv.Table.Rows(_irow).Item(COLUMNINDEX)) Then

let me know if it worked
Member 10506215 5-Feb-14 7:44am    
Thank you for your reply. The issue has been resolved :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900