i want to check a value in 2 tables. the 1st table i want to check if the value exists and from the 2ed table i samething.
i came up with this but when it's doing the second if i get error on the page.
Dim ReturnValAsInteger
Dim ReturnVal2AsInteger
Dim connAs SqlConnection =New SqlConnection(ConfigurationManager.ConnectionStrings("imacstestConnectionString").ConnectionString)Dim cmdAs SqlCommand =New SqlCommand("SELECT [ReportNumber] FROM [AppraisalSummaryBlue] WHERE ([ReportNumber] = @.ReportNumber)", conn)
'To check if the # is registered.
Dim cmd2As SqlCommand =New SqlCommand("SELECT [ReportNumber] FROM [t_RegisterInfoTemp] WHERE ([ReportNumber] = @.ReportNumber)", conn)cmd.Parameters.AddWithValue("@.ReportNumber", txtReport.Text)
cmd2.Parameters.AddWithValue("@.ReportNumber", txtReport.Text)conn.Open()
ReturnVal = Convert.ToInt32(cmd.ExecuteScalar())
conn.Close()
'This checks if the # is correct.
If ReturnVal > 0Then
'This checks if its registered with someone else.
conn.Open()
ReturnVal2 = Convert.ToInt32(cmd2.ExecuteScalar())
conn.Close()
If ReturnVal2 <> 0Then
Server.Transfer("regccinfo.aspx")Else
lblError.Text ="the # is registered with someone else."
EndIf
Else
lblError.Text ="the # does not exists."
txtReport.Focus()
EndIf
Sure would help if you would post the error that you're getting
|||this is the error i get
Value was either too large or too small for an Int32.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.OverflowException: Value was either too large or too small for an Int32.
|||Well, looks like you're sending in too big a value (absolute value speaking).
|||you mean the value in the textbox to the query ?
the value would be numbers 10 digits.
If ReturnVal > 0Then
'This checks if the certificate is registered with someone else.
Server.Transfer("regccinfo.aspx")
Else
lblError.Text ="The # is incorrect."
txtReport.Focus()
EndIf
if i have my if else statment like this then it works fine.( Now this doesnt work either.)
|||"TheInt32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647."
fromhttp://msdn2.microsoft.com/en-us/library/system.int32(vs.80).aspx
|||i got it to work. i chanded my ReturnVal as String running it like that. So far looking good.
Thanks for all your help guys
No comments:
Post a Comment