I am tasked with making a simple GUI based database viewer. The database is hosted on our schools ftp server we must use visual basic and for the most part I've got it working I can search, view, and add to the database, but editing an existing record is giving me problems.
When I attempt to update the record I get a ora-00904 error invalid identifier when not using a colon (:) in where portion of the query and an ora-01008 not variables bound with a colon (:). We so far have only really used sqldeveloper and as a final project we were asked to use Visual Basic but we never covered anything like this in class so its a challenge I suppose.
PS: I only have that portion commented out so that I could view the error.
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim strCustomerEmail As String = ""
Dim strLastName As String = ""
Dim strFirstName As String = ""
Dim strAddress As String = ""
Dim strCity As String = ""
Dim strState As String = ""
Dim intZip As Integer = 0
Dim datDateSignedUp As Date
Dim intCustomerNumber As Integer = 0
Try
strCustomerEmail = CStr(txtCustomerEmail.Text)
strLastName = CStr(txtLastName.Text)
strFirstName = CStr(txtFirstName.Text)
strAddress = CStr(txtAddress.Text)
strCity = CStr(txtCity.Text)
strState = CStr(txtState.Text)
intZip = CInt(txtZip.Text)
datDateSignedUp = CDate(txtDateSignedUp.Text)
intCustomerNumber = CInt(txtCustomerNumber.Text)
Dim sql As String = "UPDATE P_CLIENTS SET CUSTOMER_EMAIL = :CUSTOMER_EMAIL, LASTNAME = :LASTNAME, FIRSTNAME = :FIRSTNAME, ADDRESS = :ADDRESS, CITY = :CITY, STATE = :STATE, ZIP = :ZIP, DATE_SIGNED_UP = :DATE_SIGNED_UP, CUSTOMER# = :CUSTOMER# WHERE CUSTOMER_EMAIL = :EDIT_CUSTOMER_EMAIL"
Dim cmd2 As New OracleCommand(sql, conn)
conn.Open()
cmd2.Parameters.Add("CUSTOMER_EMAIL", strCustomerEmail)
cmd2.Parameters.Add("LASTNAME", strLastName)
cmd2.Parameters.Add("FIRSTNAME", strFirstName)
cmd2.Parameters.Add("ADDRESS", strAddress)
cmd2.Parameters.Add("CITY", strCity)
cmd2.Parameters.Add("STATE", strState)
cmd2.Parameters.Add("ZIP", intZip)
cmd2.Parameters.Add("DATE_SIGNED_UP", datDateSignedUp)
cmd2.Parameters.Add("EDIT_CUSTOMER_EMAIL", strEditCustomerEmail)
cmd2.CommandType = CommandType.Text
cmd2.ExecuteNonQuery()
txtCustomerEmail.Text = strEditCustomerEmail
txtLastName.Text = ""
txtFirstName.Text = ""
txtAddress.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtZip.Clear()
txtDateSignedUp.Clear()
txtCustomerNumber.Clear()
'txtCustomerEmail.Select()
txtCustomerEmail.Enabled = True
txtLastName.Enabled = True
txtFirstName.Enabled = True
txtAddress.Enabled = True
txtCity.Enabled = True
txtState.Enabled = True
txtZip.Enabled = True
txtDateSignedUp.Enabled = True
txtCustomerNumber.Enabled = True
'Catch ex As Exception
' MessageBox.Show("An error occurred while attempting to add a new record.", "Error")
Finally
conn.Close()
txtCustomerEmail.Select()
End Try
End Sub
您从参数列表中缺少Customer#
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.