|
| Re: Problem with connecting to a MS Access database (.mdb) |
 |
Mon, 31 Mar 2008 12:41:15 +000 |
thank you for your helps.
|
| Post Reply
|
| Re: Problem with connecting to a MS Access database (.mdb) |
 |
Mon, 31 Mar 2008 12:51:09 +000 |
ekb:thank you for your helps.
pleasure to help you.. and dont forget to mark the answer and resolve the
thread.. Thanx./.
|
| Post Reply
|
| Problem with connecting to a MS Access database (.mdb) |
 |
Mon, 31 Mar 2008 13:33:49 +000 |
Here is my code:
1 Dim strSQL As String2 strSQL = "SELECT * From [user] WHERE
username='" & user.Text & "' AND password = '" &
password.Text & "'"
3 4 Dim MemberDataConn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Server.MapPath("App_Data/tournament.mdb"))
5 6 Dim MemberCommand As New OleDbCommand(strSQL, MemberDataConn)
7 MemberDataConn.Open()
8 Dim MemberDBReader As OleDbDataReader
9 10 MemberDBReader = MemberCommand.ExecuteReader()
11 If MemberDBReader.Read() Then
12 Session("UserName") = user.Text
13 Else
14 ErrorLabel.Text = "Sorry no matching user name and password is
found."
15 Session("UserName") = ""
16 End If
17 MemberDBReader.Close()
18 MemberDataConn.Close()
19 20 If Session("UserName") <> "" Then
Server.Transfer("youare.aspx")
The problem is at the second line. If I remove "[ ]" from the table
name (user), my code just doesn't work. I looked up at different sources, they
do not have the "[ ]" around their table names. Why my code needs the
"[ ]" then? and what differences does it make to have or not to have
"[ ]" ?
thank you for your helps
|
| Post Reply
|
| Re: Problem with connecting to a MS Access database (.mdb) |
 |
Mon, 31 Mar 2008 14:44:45 +000 |
ekb:strSQL = "SELECT * From [user] WHERE username='" & user.Text
& "' AND password = '" & password.Text & "'"
that is because "user" would be a keyword / reserve word in MS
Access... just like Sql Server; so if we use any reserve words in our table as
tablename or fieldname then it is required to be enclosed in "[ ]"..
hope it helps./.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|