Hi, i come out with this codes but there are some error at the 3 connections. Bascially this codes are to increment the roomID in db. I had three SQL statments and created 3 connections.
If i command this line "dr = cmd.ExecuteReader()" they will show "The ConnectionString property has not been initialized." in this line "cmd2.Connection.Open()".
If i didn;t command this "dr = cmd.ExecuteReader()" it will said "No value given for one or more required parameters."
What are this two error msg means?
Dim z As Integer
Dim ID As Integer
For a = 1 To i
Dim strSQL1 As String = "Select Max(ID) as z from roomDet"
z += 1
Dim strSQL2 As String = "INSERT INTO roomDet ([roomID],[branch]) VALUES('" & ID & "','" & DropDownList1.SelectedValue & "')"
Dim strSQL3 As String = "UPDATE roomDet SET status = 'available' WHERE branch = '" + DropDownList1.SelectedValue + " ' "
Dim cmd As New OleDbCommand(strSQL1, cnn)
Dim cmd2 As New OleDbCommand(strSQL2, cnn)
Dim cmd3 As New OleDbCommand(strSQL3, cnn)
Dim dr As OleDbDataReader
cmd.Connection.Open()
'cmd.ExecuteNonQuery()
dr = cmd.ExecuteReader()
'cmd.ExecuteReader(CommandBehavior.CloseConnection)
cmd.Connection.Close()
cmd.Connection.Dispose()
cmd2.Connection.Open()
cmd2.ExecuteNonQuery()
cmd2.Connection.Close()
cmd3.Connection.Open()
cmd3.ExecuteNonQuery()
cmd3.Connection.Close()
Next
Regards
tiffany
If i command this line "dr = cmd.ExecuteReader()" they will show "The ConnectionString property has not been initialized." in this line "cmd2.Connection.Open()".
If i didn;t command this "dr = cmd.ExecuteReader()" it will said "No value given for one or more required parameters."
What are this two error msg means?
Dim z As Integer
Dim ID As Integer
For a = 1 To i
Dim strSQL1 As String = "Select Max(ID) as z from roomDet"
z += 1
Dim strSQL2 As String = "INSERT INTO roomDet ([roomID],[branch]) VALUES('" & ID & "','" & DropDownList1.SelectedValue & "')"
Dim strSQL3 As String = "UPDATE roomDet SET status = 'available' WHERE branch = '" + DropDownList1.SelectedValue + " ' "
Dim cmd As New OleDbCommand(strSQL1, cnn)
Dim cmd2 As New OleDbCommand(strSQL2, cnn)
Dim cmd3 As New OleDbCommand(strSQL3, cnn)
Dim dr As OleDbDataReader
cmd.Connection.Open()
'cmd.ExecuteNonQuery()
dr = cmd.ExecuteReader()
'cmd.ExecuteReader(CommandBehavior.CloseConnection)
cmd.Connection.Close()
cmd.Connection.Dispose()
cmd2.Connection.Open()
cmd2.ExecuteNonQuery()
cmd2.Connection.Close()
cmd3.Connection.Open()
cmd3.ExecuteNonQuery()
cmd3.Connection.Close()
Next
Regards
tiffany