Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Sql Table Using VB
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00735969
Message ID:
00736186
Views:
13
Hi Cathi,

Thank you for your help.

Sometimes I get confused. I was looking at it from the output side instead of the input side. Filenum exists in the output only. I needed to use OrderNum instead of FileNum in the parameter.

Thanks again.
Roland

=============================================================


>Hi Roland,
>
>It appears that the DataTable "NhdDailyOrders" in DataSet "NhdCreateReportOrders_Ds" does not have the field name called "FileNum". I would recommend tracing through your code where you fill this DataSet and confirm that the field exists. Your sample code does not provide the information for how you fill this DataTable.
>
>>Hi,
>>
>>I' am trying to update a table using a 2nd SQLDataAdpater which is defined in code, for each row in a different dataset filled from SqlDataAdapter1 which is created using the SqlDataAdapter Wizard.
>>-
>>-
>>-
>> ' NhdTransaction Update Command String
>> Dim strNhdTransUpdateCommand As String
>> strNhdTransUpdateCommand = "UPDATE dbo.NhdTransaction " & _
>> "SET dbo.NhdTransaction.NhdOrderSent = 1, " & _
>> "dbo.NhdTransaction.NhdOrderDate = GETDATE()" & _
>> "WHERE dbo.NhdTransaction.FileNum=@FileNum"
>>-
>>-
>>-
>>-
>> NhdCreateReportOrders_Ds.WriteXml("F:\OfficeManager\NhdXml\NhdDailyOrders.XML")
>> ' Send Nhd Report Order Email
>> SendNhdEmail()
>> ' Update NhdTransaction Table for Orders Sent
>> Dim myNhdUpdateCommand As New _
>> SqlCommand(strNhdTransUpdateCommand, SqlConnection1)
>> myNhdUpdateCommand.CommandType = CommandType.Text
>> Dim DaUpdateNhdTrans As New SqlDataAdapter()
>> DaUpdateNhdTrans.UpdateCommand = myNhdUpdateCommand
>> myNhdUpdateCommand.Parameters.Add("@FileNum", SqlDbType.Int)
>> SqlConnection1.Open()
>> For Each myDataRow In NhdCreateReportOrders_Ds.Tables("NhdDailyOrders").Rows
>> 'Intialize File Number Parameter
>> myNhdUpdateCommand.Parameters("@FileNum").Value = CInt(myDataRow("FileNum"))
>> myNhdUpdateCommand.ExecuteNonQuery()
>> Next
>> ' Execute Close Connection1
>> SqlConnection1.Close()
>>
>>I get the following error.
>>
>>************** Exception Text **************
>>System.ArgumentException: Column 'FileNum' does not belong to table NhdDailyOrders.
>> at System.Data.DataRow.get_Item(String columnName)
>> at NhdCreateReportOrders.NhdCreateReportOrders.Form1_Load(Object sender, EventArgs e) in C:\NhdCreateReportOrders\NhdCreateReportOrders.vb:line 170
>> at System.Windows.Forms.Form.OnLoad(EventArgs e)
>> at System.Windows.Forms.Form.OnCreateControl()
>> at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
>>
>>How do I connect the update command with the sqldatadapter2 that I declared in code? It seems to be connected to the SqlDataAdapter1 and Dataset instead of the one I coded.
>>
>>Please show me in my code how to fix this problem.
>>
>>Thanks
>>Roland
Previous
Reply
Map
View

Click here to load this message in the networking platform