Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Sub UpdateDBdata(ByVal docID As String, ByVal Revision As String)

Try

Dim connection As New SqlConnection("Server=it; Initial Catalog=qs; User ID=sa; pwd=sqldata")

Dim command As New SqlCommand("UpdateRev", connection)

command.CommandType = CommandType.StoredProcedure

 

Dim param_Revision As SqlParameter

param_Revision = command.Parameters.Add("@Rev_n", SqlDbType.Char, 6)

param_Revision.Value = "REVVV"

Dim param_ID As SqlParameter

param_ID = command.Parameters.Add("@DocID", SqlDbType.Int)

param_ID.Value = docID

 

connection.Open()

command.ExecuteNonQuery()

connection.Close()

 

Catch ex As Exception

checkError.Text = ex.ToString()

checkError.Visible = True

End Try

End Sub

 

 

The Debugger shows error:

 

System.FormatException: Input string was not in a correct format. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Test.Grid.UpdateDBdata(String docID, String Revision) in C:\Inetpub\wwwroot\Test\Grid.aspx.vb:line 140

Posted

I believe that when you are using a SQLCommand object that is calling a stored procedure you need to set the CommandType, which you did, as well as the CommandText, which is the name of the stored proc.

I'm also not sure that you need the '@' symbol in your parameter names. Try changing those 2 things and see if you get a different error message, or better yet, working code.

Wanna-Be C# Superstar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...