hi igot some erro with this code vb.net 2008 cmd.ExecuteNonQuery() error
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cmd As New OleDb.OleDbCommand


    If Not cn.State = ConnectionState.Open Then
        'open connection if it is not yet open
        cn.Open()
    End If

    cmd.Connection = cn
    'check whether add new or update
    If Me.TextBox1.Tag & "" = "" Then
        'add new 
        'add data to table
        cmd.CommandText = "INSERT INTO [table1](tyname, lat, lon, pressure) " & _
                        "VALUES(" & Me.TextBox1.Text & ",'" & Me.TextBox2.Text & "','" & _
                        Me.TextBox3.Text & "','" & Me.TextBox4.Text & "')"
        cmd.ExecuteNonQuery()
    Else
        'update data in table
        cmd.CommandText = "UPDATE [table1] " & _
                    " SET tyname=" & Me.TextBox1.Text & _
                    ", lat='" & Me.TextBox2.Text & "'" & _
                    ", lon='" & Me.TextBox3.Text & "'" & _
                    ", pressure='" & Me.TextBox4.Text & "'" '& _
        '" WHERE tyname=" & Me.TextBox1.Tag
        cmd.ExecuteNonQuery()
    End If
    'refresh data in list
    RefreshData()
    'clear form
    Me.Button4.PerformClick()

    'close connection
    cn.Close()
End Sub
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.