Last post Mar 28, 2011 10:12 PM by ammini
Mar 24, 2011 04:23 PM|ammini|LINK
I can't figure out whats wrong with my contact page. I am getting this error when executing. It complied fine, I see the page as it suppose to. Then I enter all my contact information and click submit I am getting this error. Can someone guide me. Thanks.
Here is the error msg
must declare the scalar variable @txtSubject
Here is the part of relevant code
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim ContactDataSource As New SqlDataSource()
ContactDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
ContactDataSource.InsertCommandType = SqlDataSourceCommandType.Text
ContactDataSource.InsertCommand = "INSERT INTO Enquery (EnqSubject,EnqFirstname, EnqLastname,EnqContactNumber,EnqEmail,EnqMsg,EnqDateTimeStamp,EnqIPAddress) values (@txtSubject, @txtFirstname, @txtLastname,@txtPhone,@txtEmail,@txtMsg, @txtDateTimeStamp,@txtIpAddress)"
1. the variable that start with Enq are field names in my table
2 the variable that start with txt are the name of my text controls in the contact aspx page.
3. enviroment - sqlserver, asp.net vs 2008
If you need any more iinfo, please let me know. Looking forward to some response.
Mar 24, 2011 04:30 PM|limno|LINK
Change your code to this way:
ContactDataSource.InsertCommand = "INSERT INTO Enquery (EnqSubject,EnqFirstname, EnqLastname)
values (@EnqSubject, @EnqFirstname, @EnqLastname)"
Mar 28, 2011 07:53 PM|ammini|LINK
Thank you so much. I am sorry I didnt' reply you immediatly. Usually when I post I will get an email for every response for my post and this time I didn't even get one reply and I was dissappointed. So I thought I will sign in here and ask for more help
and happend to see your helping hand. I will try as soon as possible after my dinner or first thingi in the morning and let you know. I apperciate your help,. Bye for now.l
Mar 28, 2011 10:12 PM|ammini|LINK
Thank you so much. Yes it took care of it. buty ou know if I get out of one, another one pop up:). let see if I can sort it out and I will post it if I can't. But that has nothing to do with this. You helped a lot, God bless you.