Page 1 of 1

Access question

Posted: Thu Feb 23, 2006 5:37 pm
by bitWISE
So I'm doing this class project and although it doesn't require access it's the simplest solution for a database on my localhost.

I have a schema like this:
member{
UserID, PK
Username,
Password
}

And in mysql I would insert a row like this:
INSERT INTO member VALUES(NULL, 'bitWISE', '1234')

What do I put in place of NULL to get Access to autogenerate the next PK value? Can it do that?

Posted: Thu Feb 23, 2006 5:41 pm
by Fender
Just make that column "autonumber" type, IIRC. You don't need to specify it in the insert.

Posted: Thu Feb 23, 2006 6:28 pm
by bitWISE
Thanks man. That did it. Guess I should have tried looking around in access more.

Posted: Thu Feb 23, 2006 9:20 pm
by bitWISE
Damnit...one query just refuses to work right:

Code: Select all

aspBoard.InsertQuery("INSERT INTO post (ForumID,ThreadID,UserID,Text,Timestamp) VALUES(" & forumId & "," & threadId & "," & userId & ",'" & post & "','" & Now() & "')")
VB.NET using a helper class to cut down on the redundancy of ASP's databasing.

Posted: Thu Feb 23, 2006 10:14 pm
by mjrpes
Could it possibly be that Text is a special keyword in Access? You can use brackets around field names to explicitly tell Access to treat it as a field name. E.g., "INSERT INTO post ([ForumID], [ThreadID], ... ", etc.

Posted: Thu Feb 23, 2006 10:16 pm
by mjrpes
Then again, you are using VB.NET. So I don't know if the OLE driver (I guess that's what VB.NET is using to work with Access) you're using would include that already in the parser.

Worth a shot :)

Posted: Thu Feb 23, 2006 11:22 pm
by bitWISE
mjrpes wrote:Then again, you are using VB.NET. So I don't know if the OLE driver (I guess that's what VB.NET is using to work with Access) you're using would include that already in the parser.

Worth a shot :)
Well I have a similar query that works. But you're right. I bet Text is fucking me over. Ill try changing it.