|
-
Feb 22nd, 2004, 03:00 PM
#1
Thread Starter
Lively Member
VB.NET and the SQLAdapter UPDATE command problem [RESOLVED]
I am trying to use VB.NET to update a record in my database. I am using the below code:
Code:
Dim RowsAffected As Integer = 0
SqlConnection1.Open()
With SqlUpdateCommand1
.Parameters("@Company_ID").Value = "COMPID"
.Parameters("@Company_Name").Value = "COMPNAME"
.Parameters("@Contract").Value = "CONTRACT"
.Parameters("@Original_ID").Value = 2
End With
SqlUpdateCommand1.ExecuteNonQuery()
SqlConnection1.Close()
When it gets to the SqlUpdateCommand1.ExecuteNonQuery() it crashes out and says:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
The SQL Update statement it should be attempting to execute is below:
UPDATE TEST SET Company_ID = @Company_ID, Contract = @Contract, Company_Name = @Company_Name WHERE (ID = @Original_ID); SELECT ID, Company_ID, Contract, Company_Name FROM TEST WHERE (ID = @ID)
Does anyone know what this problem could be or how to fix it? From my understanding I am doing everything correctly and that error means absolutely nothing to me (gives NO detail).
Last edited by JohnVM; Feb 22nd, 2004 at 03:14 PM.
-
Feb 22nd, 2004, 03:14 PM
#2
Thread Starter
Lively Member
I have been working on fixing this for 3 hours and of course right after I post it I find the solution.
It was VB being retarded and automatically adding that SELECT at the end of the command. I removed that statement since it was not needed at all (everything after the and then it worked perfectly.
*RESOLVED*
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|