Access question

Open discussion about any topic, as long as you abide by the rules of course!
Post Reply
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Access question

Post 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?
Fender
Posts: 5876
Joined: Sun Jan 14, 2001 8:00 am

Post by Fender »

Just make that column "autonumber" type, IIRC. You don't need to specify it in the insert.
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Post by bitWISE »

Thanks man. That did it. Guess I should have tried looking around in access more.
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

Post 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.
mjrpes
Posts: 4980
Joined: Tue Nov 28, 2000 8:00 am

Post 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.
mjrpes
Posts: 4980
Joined: Tue Nov 28, 2000 8:00 am

Post 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 :)
[size=85]yea i've too been kind of thinking about maybe a new sig but sort of haven't come to quite a decision yet[/size]
bitWISE
Posts: 10704
Joined: Wed Dec 08, 1999 8:00 am

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