Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run time error in code example after i added variables

Status
Not open for further replies.

melrse

Programmer
Dec 13, 2000
25
US
Hi-I am getting a run time error when I run this .aspx form only on the intranet. When run locally, it runs ok. It does not do a lot yet. Can someone take a look at it and see if there is anything wrong that may be causing the application run time error? It appears to have started after I added the variables to represent the text box to pass to the value in sql insert.
thanks
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
Sub Button_Click(s as Object, e as EventArgs)
Dim conPACESurvey as SQLConnection
Dim strInsert as String
Dim cmdInsert as SqlCommand
conPACESurvey = New SqlConnection("Server=xxx;UID=xx;PWD=xx; database=xxxxxx")
strInsert = "Insert Participant (surveyyear,entrydate,returneddate) Values('2007',GetDate(),@ReturnedDate)"
cmdInsert = New SqlCommand( strInsert, conPACESurvey )

cmdInsert.Parameters.AddWithValue("@ReturnedDate", Freturneddate.Text)

conPACESurvey.Open()
cmdInsert. ExecuteNonQuery ()
conPACESurvey. Close()
End Sub
</Script>
<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Participant Survey</title>
</head>
<body>
<form Runat = "Server">
&nbsp;<asp:Label ID="Label2" runat="server" Text="PACE CNY PARTICIPANT SURVEY" Width="424px"></asp:Label><br />
<br />
<asp:Label ID="Label1" runat="server" Text="Survey Returned Date" Width="147px"></asp:Label>
<asp:TextBox ID="Freturneddate" runat="server" Style="border-right: blue thin solid;
border-top: blue thin solid; border-left: blue thin solid; border-bottom: blue thin solid"></asp:TextBox><br />

<br />

<asp:Button ID="SubmitButton" Height="58px" Text="Submit Survey" OnClick="Button_Click" Runat="Server" Width="98px"/>


</form>

</body>
</html>
 
Does it happen on the Submit Survey button click? I set that code up and the page seems to load ok.

What is the error?

Are you doing this in Visual Studio? (if yes, 2003 or 2005?)


Also, "Insert Participant" should be "Insert INTO Participant"

Senior Software Developer
 
After you compiled the project, did you copy the .dll generated in the /bin directory on your local machine to the /bin directory on the machine that hosts the intranet?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
-I am using Visual Web Developer 2005 Express Edition.
-I stuck .sln and .suo which were created when I did the .aspx in Visual Web Developer. I am poking around for the dll.
Thanks very much. 2 weeks late for project completion and do appreciate the help.
 
Server Error in '/intranet' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

This is the actual message. However, no errors occur viewing it on the local machine.
 
Log onto the server, either console or Remote Desktop, open a browser to your project using and recreate the error there. It will tell you more about what is really wrong.

You could change the Custom Errors tag in the web.config file to show you the errors remotely, but if this is your production/live server I wouldn't... just use the method above.


Senior Software Developer
 
erver Error in '/intranet' Application.
________________________________________
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'AddWithValue' is not a member of 'System.Data.SqlClient.SqlParameterCollection'.

Source Error:


Line 11: strInsert = "Insert INTO Participant (surveyyear,entrydate,returneddate) Values('2007',GetDate(),@ReturnedDate)"
Line 12: cmdInsert = New SqlCommand( strInsert, conPACESurvey )
Line 13: cmdInsert.Parameters.AddWithValue("@ReturnedDate", Freturneddate.Text)
Line 14: conPACESurvey.Open()
Line 15: cmdInsert. ExecuteNonQuery ()

ok that was extemely helpful as it now tells me something.
ok what is it telling me exactly.
 
it liked that. no errors.
do i need to set all of my form stuff up like this - such as my radio buttons and all?
i had this in php/mysql and basically you just passed the label of the field to the insert statement so i am kind of not used to having to set up paramaters and all to get the form input into the dang file.
Thanks so very much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top