Using ASP.NET 2005
I was away from this project for months...
It is an event scheduling page to allow customers to select a date from the calendar, fill out name address etc and then it would email them and me notifying me of someone visiting and the details (all subject to approval later…)
I created a Stored Procedure and it sends data to add a record to the table. The page is supposed to send data to that Stored Procedure.
The problem now is I am getting an error at the bottom of the page
sqlAdapt and sqlCmd are not declared (noted in Red in the code below)
Can someone help me figure out what I need to do to add these back in?
I want to use most of my code and not re-write a bunch of stuff.
Here is my code:
Note some of it is removed to save space
DougP
< I Built one
I was away from this project for months...
It is an event scheduling page to allow customers to select a date from the calendar, fill out name address etc and then it would email them and me notifying me of someone visiting and the details (all subject to approval later…)
I created a Stored Procedure and it sends data to add a record to the table. The page is supposed to send data to that Stored Procedure.
The problem now is I am getting an error at the bottom of the page
sqlAdapt and sqlCmd are not declared (noted in Red in the code below)
Can someone help me figure out what I need to do to add these back in?
I want to use most of my code and not re-write a bunch of stuff.
Here is my code:
Note some of it is removed to save space
Code:
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'If Not Page.IsPostBack Then
Dim CrLf As String = Chr(13) & Chr(10)
'save to database
Try
' create connection to db
Dim cnBKTest As Data.SqlClient.SqlConnection
' build connection string to db
cnBKTest = New Data.SqlClient.SqlConnection("Server=took this out for security")
' create command for sp
Dim cmdTest As New Data.SqlClient.SqlCommand("sp_InsertIntoR2D2Events", cnBKTest)
' specify command type as stored procedure
cmdTest.CommandType = Data.CommandType.StoredProcedure
' set up prameters for stored Proc
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@TestParam", Data.SqlDbType.VarChar, 10))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@EventDate", Data.SqlDbType.SmallDateTime))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@EventStartTime", Data.SqlDbType.SmallDateTime))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@EventEndTime", Data.SqlDbType.SmallDateTime))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@ContactFName", Data.SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@ContactLName", Data.SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@ContactPhone", Data.SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New Data.SqlClient.SqlParameter("@LocationName", Data.SqlDbType.NVarChar, 50))
'put form values into parameters for Stored Procedure
cmdTest.Parameters("@EventDate").Value = Me.txtDateChoosen.Text
cmdTest.Parameters("@EventStartTime").Value = Me.ddlStartTime.Text
cmdTest.Parameters("@ContactFName").Value = Me.txtContactFName.Text
cmdTest.Parameters("@ContactLName").Value = Me.txtContactLName.Text
cmdTest.Parameters("@ContactPhone").Value = Me.txtContactPhone.Text
cmdTest.Parameters("@LocationName").Value = Me.txtLocation.Text
cnBKTest.Open()
cmdTest.ExecuteNonQuery()
cnBKTest.Close()
Dim dt As New Data.DataTable()
Dim myConnection As New Data.SqlClient.SqlConnection("Server=took this out for security")
'Dim strSQL As String = "Insert into R2D2Events (EventDate, EventStartTime, EventEndTime, EventType, Company, ContactFName, ContactLName, ContactPhone, LocationName, LocationAddr1, LocationAddr2, LocationCity, LocationState, LocationZip, Email, Over18, SpecialInstructions) " & _
'" VALUES (" & Me.txtDateChoosen.Text & ", " & Me.ddlStartTime.Text & ", " & Me.ddlEndTime.Text & ", " & Me.ddlEventType.Text & ", " & Me.txtCompany.Text & ", " & Me.txtContactFName.Text & ", " & Me.txtContactLName.Text & ", " & Me.txtContactPhone.Text & ", " & Me.txtLocation.Text & ", " & Me.txtLocationAddr1.Text & ", " & Me.txtLocationAddr2.Text & ", " & Me.txtLocationCity.Text & ", " & Me.txtLocationState.Text & ", " & Me.txtLocationZip.Text & ", " & Me.txtEmail.Text & ", " & Me.txtSpcialInstructions.Text & ", " & Me.chkIm18yearsold.Text & ")"
Dim strSQL As String = "sp_InsertIntoR2D2Events"
Dim myCommand As New Data.SqlClient.SqlCommand(strSQL, myConnection)
myCommand.ExecuteNonQuery()
sqlAdapt.SelectCommand = sqlCmd [COLOR=red] <both are missing [/color]
Catch ex As Exception
lblErrorStatus.Text = ex.ToString()
End Try
DougP
< I Built one