im helping out a friend doing some ASP.NET VB work, but i cant figure out why its inserting into the database twice, im hoping somewhere here can :D
Imports System.Data.OleDb
Partial Class admin
Inherits System.Web.UI.Page
Protected Sub book_appointment(ByVal sender As Object, ByVal e As System.EventArgs) Handles book.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim strSQL As String
Dim book_date As String
Dim book_time As String
Dim service As String
Dim username As String
book_date = bookdate.Text
book_time = booktime.Text
service = bookservice.Text
username = Request.Cookies("username").Value.ToString()
strSQL = "INSERT INTO booking ([username], [date], [time], [service]) VALUES ('" _
& username & "', '" _
& book_date & "', '" _
& book_time & "', '" _
& service & "')"
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=" & Server.MapPath("database/Admin_Database.mdb") & ";")
myCommand = New OleDbCommand(strSQL, myConnection)
Try
myConnection.Open()
myCommand.ExecuteScalar()
myConnection.Close()
Catch ex As Exception
output.Text = ex.ToString()
End Try
output.Text = "Appointment Booked!"
End Sub
End Class
Question
mikeaag
hey,
im helping out a friend doing some ASP.NET VB work, but i cant figure out why its inserting into the database twice, im hoping somewhere here can :D
Imports System.Data.OleDb Partial Class admin Inherits System.Web.UI.Page Protected Sub book_appointment(ByVal sender As Object, ByVal e As System.EventArgs) Handles book.Click Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim strSQL As String Dim book_date As String Dim book_time As String Dim service As String Dim username As String book_date = bookdate.Text book_time = booktime.Text service = bookservice.Text username = Request.Cookies("username").Value.ToString() strSQL = "INSERT INTO booking ([username], [date], [time], [service]) VALUES ('" _ & username & "', '" _ & book_date & "', '" _ & book_time & "', '" _ & service & "')" myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _ & "Data Source=" & Server.MapPath("database/Admin_Database.mdb") & ";") myCommand = New OleDbCommand(strSQL, myConnection) Try myConnection.Open() myCommand.ExecuteScalar() myConnection.Close() Catch ex As Exception output.Text = ex.ToString() End Try output.Text = "Appointment Booked!" End Sub End ClassThanks in advance
Link to comment
Share on other sites
9 answers to this question
Recommended Posts