Re: INSERT row into Access



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
> >
>
>
>
.



Relevant Pages

  • Re: is thier a Activex file to read MDB files
    ... Please Brendan Reynolds ... 2ndly their is three versions of the MS access database driver in MS windows ... Does it have instructions in MS VBasic V6 like ... J Lex Dean ...
    (microsoft.public.access.modulesdaovba)
  • Re: link table to sql server dynamicaly
    ... "Brendan Reynolds" wrote: ... > GlobalSign digital certificate is a forgery and should be deleted without ... The problem is that some of that sql server tables can be modified ... Of corse the link in ms access database for the modified table ...
    (microsoft.public.data.ado)
  • Re: INSERT row into Access
    ... Try putting square brackets around it ... ... Brendan Reynolds ... > Beginner question for "Insert". ... > table within an Access Database (Access is being used for prototyping, ...
    (microsoft.public.data.ado)
  • Re: workgroup information file using OLE DB
    ... "Brendan Reynolds" wrote: ... I know no one is using it since its the test database. ... >> My main intent is to print product labels using a query or exported excel ... >> spreadsheet from the Access Database. ...
    (microsoft.public.access.security)
  • Re: The Object Doesnt contain the Automation object Date
    ... Ironically enough, you probably need to *add* some square brackets, around ... I'm getting no error message but the text box is saying #Name? ... Brendan Reynolds wrote: ... and methods it make available for Automation operations. ...
    (microsoft.public.access.formscoding)