Question:

I cant update my data or datasheet. My database is in SQL.

by  |  earlier

0 LIKES UnLike

I had create a database call Customers. I wanted to update the CPHONE. After running it i got "err msg" instead of updating the CPHONE. Please help.

cnnstr = "Provider=SQLOLEDB;" & _

"Data Source=ABC\SQLEXPRESS;" & _

"Initial Catalog= XYZ;" & _

"Integrated Security=SSPI;" & _

"uid=;pwd=;"

Dim myConnection As OleDbConnection = New OleDbConnection(cnnstr)

myConnection.Open()

Dim SQLStr As String

SQLStr = "update Customers set CPHONE= " & NewMobileTextBox.Text & " where CNAME =" & CustomerNameTextBox.Text & " "

Dim myCmd As New OleDbCommand

myCmd.Connection = myConnection

myCmd.CommandText = SQLStr

myCmd.CommandType = CommandType.Text

Try

myCmd.ExecuteNonQuery()

MessageBox.Show("Customer account updated")

Catch ex As Exception

MessageBox.Show("err msg")

myConnection.Close()

End Try

 Tags:

   Report

1 ANSWERS


  1. SQLStr = "update Customers set CPHONE= " & NewMobileTextBox.Text & " where CNAME =" & CustomerNameTextBox.Text & " "

    ==>

    SQLStr = "update Customers set CPHONE= '" & NewMobileTextBox.Text & "' where CNAME ='" & CustomerNameTextBox.Text & "' "

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.