Hi..

i'm new in vb.net and i have problem with my project. can anyone help me with this problem..

-update button

  Dim con As New OleDb.OleDbConnection(My.Settings.TREViS_03_ConnectionString)
  Dim com As New OleDb.OleDbCommand
    Dim adap As New OleDb.OleDbDataAdapter
    Dim ds As New DataSet
    con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Yaya\Desktop\TREViS(03).mdb;Persist Security Info=True")
    con.Open()

    Dim cmd As OleDbCommand = New OleDbCommand("update STUDENT set [Student Name]=@sName where [Student HP_No]=@sHPNo and [Student Email]=@sEmail", con)

    '" & txtName.Text & "',Student HP No='" & mtxPhoneNo.Text & "',Student Email='" & txtEmail.Text & "' Where Student ID ='" & txtID.Text & "'", con)

    cmd.Parameters.AddWithValue("@sName", txtName.Text)
    cmd.Parameters.AddWithValue("@sHPNo", mtxPhoneNo.Text)
    cmd.Parameters.AddWithValue("@sEmail", txtEmail.Text)


    com.Connection = con
    com.ExecuteNonQuery()
    adap = New OleDbDataAdapter("select * from STUDENT", con)
    adap.Fill(ds, "1")
    STUDENTDataGridView.DataSource = ds.Tables("1")

error = Command text was not set for the command object. ( at com.ExecuteNonQuery() )

-delete button

Dim con As New OleDb.OleDbConnection(My.Settings.TREViS_03_ConnectionString)
    Dim com As New OleDb.OleDbCommand
    Dim adap As New OleDb.OleDbDataAdapter
    Dim ds As New DataSet
    Dim str As String
    con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Yaya\Desktop\TREViS(03).mdb;Persist Security Info=True")
    con.Open()
    str = "delete from STAFF where Staff ID like '" & txtKeyword.Text & "%'"
    com.CommandText = str
    com.Connection = con
    com.ExecuteNonQuery()
    adap = New OleDbDataAdapter("select * from STAFF", con)
    adap.Fill(ds, "1")
    STUDENTDataGridView.DataSource = ds.Tables("1")

error = Syntax error (missing operator) in query expression 'Staff ID like '%''. ( at com.ExecuteNonQuery() )

anyone can help me?

check ur syntax for delete

"delete from STAFF where Staff ID like  '" & txtKeyword.Text & "%" + "'"

for ur update query try doing this...

"update tablename set Student_Name='"+txtName.Text+"' where Student_HP_No='"+mtxPhoneNo.Text+"' and  Student_Email='"+txtEmail.Text+"'"

I am not so very sure but check if we can add spaces between column names....please do confirm....

One more thing is u can use Debug.Print("your commandtext") - to find our what the query is....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.