Re: INSERT row into Access
- From: "Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Dec 2005 11:58:49 -0000
'User' is a reserved word. Try putting square brackets around it ...
"INSERT INTO TestTable([User], Comment) VALUES ('user4', 'It Works')"
--
Brendan Reynolds
"Macs" <Macs@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D9D0D534-C556-4FD6-AC90-8778D5E71E4A@xxxxxxxxxxxxxxxx
> Beginner question for "Insert". I'm trying to insert a simple row into a
> table within an Access Database (Access is being used for prototyping, end
> DB
> will be SQL Server). I've tried numerous statements, but keep getting
> syntax
> error. I've now created a test db table with two fields and a test
> routine
> (Ignore the commented out "Select" statement - I used it to verify I was
> correctly connecting to the DB):
>
> Try
> ' Set Connection String
> strConnectionString = pfSetConnString()
> ' Create the connection object
> objConn = New OleDbConnection(strConnectionString)
>
> ' Connect to DB
> objConn.Open()
>
> ' Select - Set SQL Statement
> ' strSQL = "SELECT Comment FROM TestTable WHERE User = 'user3'"
> ' Apply Statement
> ' objCmd = New OleDbCommand(strSQL, objConn)
> ' Execute Command and Capture
> ' strTestComment = objCmd.ExecuteScalar
>
> ' Insert - Set SQL Statement
> strSQL = "INSERT INTO TestTable(User, Comment) VALUES ('user4',
> 'It Works')"
> ' Apply Statement
> objCmd = New OleDbCommand(strSQL, objConn)
> ' Execute Command
> objCmd.ExecuteNonQuery()
>
> ' Close the Connection
> objConn.Close()
>
> Catch ex As Exception
> ' Error Processing
> strMessage = ex.Message
> End Try
>
> Any suggestions?
>
> Thanks,
>
> Macs
>
.
- Follow-Ups:
- Re: INSERT row into Access
- From: Macs
- Re: INSERT row into Access
- Prev by Date: Re: Datagridview new row
- Next by Date: Re: Nested Datagrid
- Previous by thread: Re: Datagridview new row
- Next by thread: Re: INSERT row into Access
- Index(es):
Relevant Pages
|
|