calling stored procedures for update in asp.net application

miejan

New member
Joined
Mar 9, 2005
Messages
4
Basically, I have part of this code for calling the stored procedures for update purpose:

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Dim strMessage As String
Dim moddate As DateTime
Dim createdate As DateTime
update strd proc
Btn_Cancel.Visible = False
Btn_Save.Text = "Add"

lblEmpNo.Visible = False
lblIssueDate.Visible = False
lblReturnedDate.Visible = False
strMessage = "Update successfull"
t_Serial.ReadOnly = True


Dim dbconn As New SqlConnection(strconn)
dbconn.Open()

Dim cmdNew As New SqlCommand("SPHERE", dbconn) calling the stored procedure here

cmdNew.CommandType = CommandType.StoredProcedure

createdate = Now()
moddate = Now()

Dim Selected As DateTime
Dim IssueDate As String
Dim ReturnDate As String

IssueDate = Issue_Day.SelectedValue & Issue_Month.SelectedValue & Issue_Year.SelectedValue
ReturnDate = ReturnedDate_Day.SelectedValue & ReturnedDate_Month.SelectedValue & ReturnedDate_Year.SelectedValue

IssueDate = CDate(Selected)
ReturnDate = CDate(Selected)


cmdNew.Parameters.Add("@barcode_no", SqlDbType.VarChar, 20).Value = t_Serial.Text & ""
cmdNew.Parameters.Add("@employee_id", SqlDbType.BigInt).Value = CInt(t_EmpNo.Text & "")
cmdNew.Parameters.Add("@issue_date", SqlDbType.BigInt).Value = IssueDate
cmdNew.Parameters.Add("@return_date", SqlDbType.DateTime).Value = ReturnDate


Dim cmdRun As New SqlDataAdapter
cmdRun.InsertCommand = cmdNew
cmdRun.InsertCommand.ExecuteNonQuery()


Dim strScript As String = "<script language=JavaScript>"
strScript += "alert(""" & strMessage & """);"
strScript += "</script>"

If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strScript)
End If


End Sub

------
whenever I fill in the textbox and select for the date, and click the submit button, it does not do the update.. and the error message comes out highlighted the
cmdRun.InsertCommand.ExecuteNonQuery() part.. and says that the input is not in correct format.
Need help with this..tq=)
 
"the input is not in correct format."...do you have correct values? Put a debug step and look at the values to make sure.
 
First of all, ive detected something which is very small unseen mistake

cmdNew.Parameters.Add("@issue_date", SqlDbType.BigInt).Value = IssueDate
the BigInt should be DateTime.. doh!~

Ive run the code, it runs well for employee id field value(it does update!)but still not the date!! the date field value doesnt change at all..
it still capture todays date(current date) and not the selection date. Is it correct with the date function nway?
Need help..stuck on this.. :(
 
Back
Top