Error al insertar

01/12/2004 - 16:52 por Sandro D. Garcia | Informe spam
Hola, espero que me puedan ayudar, estoy utilizando el codigo que tengo aca
para insertar una nueva fila en una tabla de mi DB Access.

Dim myOleDbConnection As OleDb.OleDbConnection
Dim insertcommand As String
Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\lojistik\Data\clearing.mdb;User
ID=Admin;Password=;"
insertcommand = "INSERT INTO logins (user, value1) VALUES ('Korhan',
'abctest')"
myOleDbConnection = New OleDb.OleDbConnection(myConnectionString)
Dim myOleDbCommand As New OleDb.OleDbCommand(insertcommand,
myOleDbConnection)
myOleDbConnection.Open()
Dim temp_num As Integer
temp_num = myOleDbCommand.ExecuteNonQuery
myOleDbConnection.Close()

Pero recibo este error
.--
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT
INTO statement.

Source Error:
Line 109: Dim temp_num As Integer Line 110: Line 111: temp_num =
myOleDbCommand.ExecuteNonQuery Line 112: Line 113: myOleDbConnection.Close()

Los dos campos de la tabla tienen formato Texto
 

Leer las respuestas

#1 Marco Villagrana
01/12/2004 - 20:06 | Informe spam
podría ser porque 'user' es palabra reservada, intenta encerrándolo entre
corchetes
insertcommand = "INSERT INTO [logins] ([user], [value1]) VALUES ('Korhan',
'abctest')"

"Sandro D. Garcia" escribió en el mensaje
news:eW%
Hola, espero que me puedan ayudar, estoy utilizando el codigo que tengo
aca para insertar una nueva fila en una tabla de mi DB Access.

Dim myOleDbConnection As OleDb.OleDbConnection
Dim insertcommand As String
Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\lojistik\Data\clearing.mdb;User
ID=Admin;Password=;"
insertcommand = "INSERT INTO logins (user, value1) VALUES ('Korhan',
'abctest')"
myOleDbConnection = New OleDb.OleDbConnection(myConnectionString)
Dim myOleDbCommand As New OleDb.OleDbCommand(insertcommand,
myOleDbConnection)
myOleDbConnection.Open()
Dim temp_num As Integer
temp_num = myOleDbCommand.ExecuteNonQuery
myOleDbConnection.Close()

Pero recibo este error
.--
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in
INSERT INTO statement.

Source Error:
Line 109: Dim temp_num As Integer Line 110: Line 111: temp_num =
myOleDbCommand.ExecuteNonQuery Line 112: Line 113:
myOleDbConnection.Close()

Los dos campos de la tabla tienen formato Texto

Preguntas similares