Help with a datawebform

Code:
Me.SqlSelectCommand1.CommandText = "SELECT tblPRUMaster.PruID, tblPRUMaster.PruNumber, tblPRUMaster.PermitNo, " & _
        "tblPRUProduction.RptDate, tblPRUProduction.NorthOrSouth, tblPRUProduction.OilProd, " & _
        "tblPRUProduction.GasProd, tblPRUProduction.MonthlyAllowableOil, " & _
        "tblPRUProduction.MonthlyAllowableGas FROM tblPRUMaster INNER JOIN tblPRUProduction ON " & _
        "tblPRUMaster.PruID = tblPRUProduction.PruID WHERE PermitNo =  @PermitNum"

Me.SqlSelectCommand1.Connection = Me.SqlConnection1


Me.SelectCommand.Parameters.Add("@PermitNum", SqlDbType.Int)
Me.SelectCommand.Parameters("@PermitNum").Value = Integer.Parse(TextBox1.Text)

Does the above code make a difference? Also which line is the exception being raised on? If you step through the code in the debugger does TextBox1.Text contain the correct value?
 
When it gets to the last line of the code you posted above, it gives me this:

Server Error in /ProductionApplication Application.
--------------------------------------------------------------------------------

Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.

Source Error:


Line 30:
Line 31: Me.SqlSelectCommand1.Parameters.Add("@PermitNum", SqlDbType.Int)
Line 32: Me.SqlSelectCommand1.Parameters("@PermitNum").Value = Integer.Parse(TextBox1.Text)
Line 33:
Line 34: SqlConnection1


Source File: c:\inetpub\wwwroot\ProductionApplication\WebForm1.aspx.vb Line: 32

Stack Trace:


[FormatException: Input string was not in a correct format.]
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
System.Int32.Parse(String s) +38
ProductionApplication.WebForm1.InitializeComponent() in c:\inetpub\wwwroot\ProductionApplication\WebForm1.aspx.vb:32
ProductionApplication.WebForm1.Page_Init(Object sender, EventArgs e) in c:\inetpub\wwwroot\ProductionApplication\WebForm1.aspx.vb:63
System.Web.UI.Control.OnInit(EventArgs e)
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
 
Using a textbox shouldnt cause any problems, if you step through the code in a debugger waht is the value of TextBox1.text before the exception is thrown?
 
Doesnt get how far? If it crashes on the line you mentioned then it is getting that far. Also it would fail with a NullReferenceException if it was null (which a .Text proprty cant be anyway)
 
PlausiblyDamp said:
Doesnt get how far? If it crashes on the line you mentioned then it is getting that far. Also it would fail with a NullReferenceException if it was null (which a .Text proprty cant be anyway)

When I hit F5 to start the application it comes up with that error before the page loads to enter any information.
 
Okay. I put a breeak point in the very first line of code and stepped through the application. It didnt even make it past the first line.
 
Nevermind. I changed teh Datatype to NVarChar, dropped the Integer.Parse in the value and moved the two lines that define the parameter into the click command and that worked. Thanks for all your help. I really appreciate it and Im sorry to be such a pest.
 
Okay...Ive tried modifying what I had so that the information shows up in two datagrids, one for the values that are constant for all reports, and one for the values that change. When I try running what Ive got now I get the following error: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
 
Back
Top