I'm taking input from a VB.net proggie that I'm developing,
and trying to write the resulting 'record' to an SQL database table.
Can anyone help with a solution please?
Here's the complete error
-------------------------------------------------------
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
-------------------------------------------------------
I get the error when the following code is executed at the last line:
-------------------------------------------------------
New_Return.add(Receipt_Date.Value)
New_Return.add(Dealer_Code.text)
New_Return.add(Customer_Code.text)
New_Return.add(Customer_PartNo.text)
New_Return.add(Quantity_Recd.text)
New_Return.add(Our_PartNo.text)
New_Return.add(Manuf_Date.Value)
New_Return.add(InService_Date.Value)
New_Return.add(Failure_Date.Value)
New_Return.add(Failure_Code.Text)
New_Return.add(Mileage.text)
'Now write it to the table
Dim WriteItConn As New SqlConnection("Integrated Security=SSPI;Data Source=****;" _
&"Initial Catalog=Customer_Returns"
WriteItConn.Open()
Dim WriteItNow As new SqlCommand("INSERT INTO [Returned_Items] " _
&"([Receipt_Date], [Dealer_Code], [Customer_Code], [Customer_PartNo], [Quantity_Recd], " _
&"[Our_PartNo], [Manuf_Date], [InService_Date], [Failure_Date], [FailureCode], [Mileage])" _
&"VALUES ('"&New_Return(1)&"', '"&New_Return(2)&"', '"&New_Return(3)&"', '"&New_Return(4)&"', " _
&"'"&New_Return(5)&"', '"&New_Return(6)&"', '"&New_Return(7)&"', '"&New_Return(8)&"', " _
&"'"&New_Return(9)&"', '"&New_Return(10)&"', '"&New_Return(11)&"'", WriteItConn)
WriteItNow.ExecuteNonQuery()
-------------------------------------------------
If I take out the ", WriteItConn" on the end of the Insert command, I get this error:
-------------------------------------------------
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: ExecuteNonQuery: Connection property has not been initialized.
--------------------------------------------------
Any and all suggestions and help is apreciated
Sorry I've taken so much space!
Cheers
Dave
and trying to write the resulting 'record' to an SQL database table.
Can anyone help with a solution please?
Here's the complete error
-------------------------------------------------------
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
-------------------------------------------------------
I get the error when the following code is executed at the last line:
-------------------------------------------------------
New_Return.add(Receipt_Date.Value)
New_Return.add(Dealer_Code.text)
New_Return.add(Customer_Code.text)
New_Return.add(Customer_PartNo.text)
New_Return.add(Quantity_Recd.text)
New_Return.add(Our_PartNo.text)
New_Return.add(Manuf_Date.Value)
New_Return.add(InService_Date.Value)
New_Return.add(Failure_Date.Value)
New_Return.add(Failure_Code.Text)
New_Return.add(Mileage.text)
'Now write it to the table
Dim WriteItConn As New SqlConnection("Integrated Security=SSPI;Data Source=****;" _
&"Initial Catalog=Customer_Returns"
WriteItConn.Open()
Dim WriteItNow As new SqlCommand("INSERT INTO [Returned_Items] " _
&"([Receipt_Date], [Dealer_Code], [Customer_Code], [Customer_PartNo], [Quantity_Recd], " _
&"[Our_PartNo], [Manuf_Date], [InService_Date], [Failure_Date], [FailureCode], [Mileage])" _
&"VALUES ('"&New_Return(1)&"', '"&New_Return(2)&"', '"&New_Return(3)&"', '"&New_Return(4)&"', " _
&"'"&New_Return(5)&"', '"&New_Return(6)&"', '"&New_Return(7)&"', '"&New_Return(8)&"', " _
&"'"&New_Return(9)&"', '"&New_Return(10)&"', '"&New_Return(11)&"'", WriteItConn)
WriteItNow.ExecuteNonQuery()
-------------------------------------------------
If I take out the ", WriteItConn" on the end of the Insert command, I get this error:
-------------------------------------------------
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: ExecuteNonQuery: Connection property has not been initialized.
--------------------------------------------------
Any and all suggestions and help is apreciated
Sorry I've taken so much space!
Cheers
Dave