Re: INSERT row into Access
- From: "Macs" <Macs@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 24 Dec 2005 11:57:02 -0800
Brendan - It worked! Thank you!
"Brendan Reynolds" wrote:
> '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
> >
>
>
>
.
- References:
- Re: INSERT row into Access
- From: Brendan Reynolds
- Re: INSERT row into Access
- Prev by Date: Re: WriteXML
- Next by Date: Re: Query Two Databases
- Previous by thread: Re: INSERT row into Access
- Next by thread: Re: Nested Datagrid
- Index(es):
Relevant Pages
|
|