Hi all,
What's wrong with my code. I have table containing list of books with ISBN numbers. I used these ISBN numbers to go get other related informations and update my SQL table. The problem is it doesn't update my SQL table when it execute line...
.
I used MS-SQL 2k, Studio .NET 2003, WinXP. AGENT!
What's wrong with my code. I have table containing list of books with ISBN numbers. I used these ISBN numbers to go get other related informations and update my SQL table. The problem is it doesn't update my SQL table when it execute line...
Code:
objAdapter.Update(objDataSet, "DS_Books")
I used MS-SQL 2k, Studio .NET 2003, WinXP. AGENT!
Code:
Function GetTableData() As Boolean
Dim objConnection As New SqlConnection("server=SammyNoteBook;uid=sa;pwd=sa;database=Book")
Dim strSQL As String
strSQL = "SELECT ISBN,Title,Publisher,Dimension,Weight,FoundNot FROM tblISBN "
strSQL = strSQL & "WHERE (NOT (ISBN = '')) AND ((Title IS NULL) OR (Title = '') OR "
strSQL = strSQL & "(Publisher IS NULL) OR (Publisher = '') OR (Dimension IS NULL) OR (Dimension = '') OR "
strSQL = strSQL & "(Weight IS NULL) OR (Weight = '')) ORDER BY ISBN"
Dim objAdapter As New SqlDataAdapter(strSQL, objConnection)
Dim objDataSet As DataSet = New DataSet
Dim objRow As DataRow
Dim lnCount As Integer
Dim lnTotalCount As Integer
Dim strISBN As String
objAdapter.Fill(objDataSet, "DS_Books")
objConnection.Open()
For Each objRow In objDataSet.Tables(0).Rows
strISBN = objRow("ISBN")
objRow("Title") = getTitle(objRow("ISBN"))
objRow("Publisher") = GetPublisher(objRow("ISBN"))
objRow("Dimension") = getDimension(objRow("ISBN"))
objRow("Weight") = getWeight(objRow("ISBN"))
objRow("FoundNot") = getFoundNot(objRow("ISBN"))
objAdapter.UpdateCommand = New SqlCommand("spUpdateBooks", objConnection)
objAdapter.UpdateCommand.CommandType = CommandType.StoredProcedure
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@ISBN", SqlDbType.Char, 27, objRow("ISBN")))
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@Title", SqlDbType.Char, 100, objRow("Title")))
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@Publisher", SqlDbType.Char, 100, objRow("Publisher")))
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@Dimension", SqlDbType.Char, 25, objRow("Dimension")))
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@Weight", SqlDbType.Char, 10, objRow("Weight")))
objAdapter.UpdateCommand.Parameters.Add(New SqlParameter("@FoundNot", SqlDbType.Char, 3, objRow("FoundNot")))
'Next line suppose to be updating my table but it's not
objAdapter.Update(objDataSet, "DS_Books")
Next
objConnection.Close()
End Function