Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi everyone

I'm trying to insert a new item using a stored procedure. In this case if the user leaves the category id textbox empty, then it sould be inserted as a null value.

here is my code

Dim catidparam As SqlParameter
           catidparam = New SqlParameter("@Category_id", SqlDbType.Int)
           catidparam.Direction = ParameterDirection.Input
           'make null insertion Possible
           catidparam.Value = IIf(IsDBNull(txtcategoryid.Text), DBNull.Value, txtcategoryid.Text)
           myCmd.Parameters.Add(catidparam)

 

But it doesn't work. I get error message saying "input string was not in a correct format"

Please help.

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...