(
vb.net 1.1 -- sql server) i'm using following insert code. It is working fine when all the fields are filled but it is gives error when fields which allows null values are not filled...... i'm getting following errorVB.net): Input string was not in a correct format. plz suggest something, i'll be really thkful.
myConn = New SqlConnection(ConfigurationSettings.AppSettings("S qlConnection.ConnectionString"))
myConn.Open()
myComm = New SqlCommand("Add_BookDetails", myConn)
myComm.CommandType = CommandType.StoredProcedure
Dim ins As SqlParameterCollection
ins = myComm.Parameters
Dim status As String
status = 1
ins.Add("@BookID", SqlDbType.Int).Value = txtBookID.Text 'null allowed
ins.Add("@Status", SqlDbType.Int).Value = status
ins.Add("@Category", SqlDbType.VarChar).Value = txtBookCategory.Text
ins.Add("@Title", SqlDbType.VarChar).Value = txtBookTitle.Text
ins.Add("@Author", SqlDbType.VarChar).Value = txtAuthorName.Text 'null allowed
ins.Add("@Description", SqlDbType.VarChar).Value = txtDescription.Text 'null allowed
ins.Add("@ISBN_No", SqlDbType.VarChar).Value = txtISBN.Text 'null allowed
ins.Add("@Price", SqlDbType.Float).Value = txtBookPrice.Text 'null allowed
ins.Add("@PurchaseDate", SqlDbType.DateTime).Value = txtDate.Text 'null allowed
ins.Add("@PublisherName", SqlDbType.VarChar).Value = txtPublisherName.Text 'null allowed
myComm.ExecuteNonQuery()
myConn.Close()
Catch ex As Exception
Response.Write(ex.Message)
End Try
Context.Items("Message1") = "Book added successfully."
Server.Transfer("BookManagement.aspx")
Regards,
sandy