0

This is my first visit here. I need help with connection to access db from vbscript, I will appreciate any clues! This is my code:

connStr = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\Gregory\Documents\db1.accdb"
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset") 
conn.Open connStr
rs.CursorType = adOpenStatic
rs.Open "SELECT username FROM User", conn

I should also add that there is just one table in the database, called "User" and it's got three fields: username, password and realName.

7
  • What is the exact error that you are getting? Commented Jun 28, 2014 at 22:07
  • @user3786747 -- You have to have patience -- it's Saturday night (depending on where you are, of course). Commented Jun 28, 2014 at 22:13
  • This is what I am getting: Script error detected at line 19. Source line: rs.Open "SELECT username FROM User", conn Description: Syntax error in FROM clause. Commented Jun 28, 2014 at 22:29
  • You might need brackets in the rs.Open line. Commented Jun 28, 2014 at 22:30
  • 1
    I believe User is a reserved word in SQL. Try using [] around the table name: select username from [User] Commented Jun 29, 2014 at 0:43

1 Answer 1

2

I believe User is a reserved word in SQL. Try using [ ] around the table name:

select username from [User]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.