purplehaze1
Programmer
I am trying to update a record in customer table located in sybase database.
I use commandbuilder. I get following error msg. How can I fix it?
It works in SQL Server. Thanx.
ERROR [HY00] [INTERSOLV][ODBC SQL Server driver][SQL Server]
Incorrect syntax near the keyword 'DEFAULT'.
commandText built by commandbuilder.
INSERT INTO t_customer DEFAULT VALUES
.....
Public Function SaveCustomer() As Boolean
Dim strsql As String
Dim myCommand As OdbcCommand
Dim dr As DataRow, i As Integer
Try
strsql = "SELECT * FROM t_customer WHERE cust_id=" & m_custID
myCommand = New OdbcCommand(strsql, myConnection)
Dim da As New OdbcDataAdapter(myCommand)
Dim cb As New OdbcCommandBuilder(da)
Dim ds As New DataSet()
da.Fill(ds, "Customer")
If ds.Tables(0).Rows.Count = 0 Then
dr = ds.Tables(0).NewRow()
IsNew = True
GoTo SaveRecord
Else
dr = ds.Tables(0).Rows(0)
End If
SaveRecord:
dr("cust_cde") = m_custCode
dr("cust_name") = IIf(m_custName = String.Empty, Nothing, m_custName)
''Delegate for Handling RowUpdated event
AddHandler da.RowUpdated, AddressOf HandleRowUpdated
da.Update(ds, "Customer")
End Function
Private Sub HandleRowUpdated(ByVal sender As Object, ByVal e As OdbcRowUpdatedEventArgs)
...
...
...
end sub
I use commandbuilder. I get following error msg. How can I fix it?
It works in SQL Server. Thanx.
ERROR [HY00] [INTERSOLV][ODBC SQL Server driver][SQL Server]
Incorrect syntax near the keyword 'DEFAULT'.
commandText built by commandbuilder.
INSERT INTO t_customer DEFAULT VALUES
.....
Public Function SaveCustomer() As Boolean
Dim strsql As String
Dim myCommand As OdbcCommand
Dim dr As DataRow, i As Integer
Try
strsql = "SELECT * FROM t_customer WHERE cust_id=" & m_custID
myCommand = New OdbcCommand(strsql, myConnection)
Dim da As New OdbcDataAdapter(myCommand)
Dim cb As New OdbcCommandBuilder(da)
Dim ds As New DataSet()
da.Fill(ds, "Customer")
If ds.Tables(0).Rows.Count = 0 Then
dr = ds.Tables(0).NewRow()
IsNew = True
GoTo SaveRecord
Else
dr = ds.Tables(0).Rows(0)
End If
SaveRecord:
dr("cust_cde") = m_custCode
dr("cust_name") = IIf(m_custName = String.Empty, Nothing, m_custName)
''Delegate for Handling RowUpdated event
AddHandler da.RowUpdated, AddressOf HandleRowUpdated
da.Update(ds, "Customer")
End Function
Private Sub HandleRowUpdated(ByVal sender As Object, ByVal e As OdbcRowUpdatedEventArgs)
...
...
...
end sub