![]() |
|
|
#1 (permalink) |
|
Registered User
Join Date: Apr 2005
Posts: 4
|
OdbcConnection & M$ Access
Can anyone take a look at my C# code i'm using to connect to a M$ Access database and tell me what is wrong.
I'm getting the following error: ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. and the code has been attached. I keep getting an email back containing the above exception. |
|
|
|
|
|
#2 (permalink) |
|
Administrator
Join Date: Oct 2003
Posts: 1,484
|
Not quite sure whats generating that error but it could be possibly:
Code:
command.CommandType = CommandType.StoredProcedure; Code:
command.CommandType = CommandType.Text; Hope that helps
__________________
Jason Robbins jason@catalyst2.com |
|
|
|
|
|
#4 (permalink) |
|
Administrator
Join Date: Oct 2003
Posts: 1,484
|
Try replacing:
Code:
command.CommandText = "INSERT INTO Visitor(Referer, Browser) VALUES(@Referer, @Browser);";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Referer", (Request.UrlReferrer == null ? "none" : Request.UrlReferrer.ToString()));
command.Parameters.Add("@Browser", Request.UserAgent);
Code:
command.CommandText = "INSERT INTO Visitor(Referer, Browser) VALUES(" + (Request.UrlReferrer == null ? "none" : Request.UrlReferrer.ToString()) + "," + Request.UserAgent + ");";
command.CommandType = CommandType.Text;
__________________
Jason Robbins jason@catalyst2.com |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Apr 2005
Posts: 4
|
OK, so I replaced the original code with the following:
Code:
OdbcConnection connection = new OdbcConnection(AppSettings.DbConn);
OdbcCommand command = connection.CreateCommand();
command.CommandText = "INSERT INTO Visitor(Referer, Browser) VALUES('";
command.CommandText += (Request.UrlReferrer == null ? "none" : Request.UrlReferrer.ToString());
command.CommandText += "', '" + Request.UserAgent + "');";
command.CommandType = CommandType.Text;
|
|
|
|
|
|
#7 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
The probable reason you would be getting 'Operation must use an updateable query' is because the folder you have the database in does not have correct permissions. The /db has the correct permissions already and is much more secure than having the database in the wwwroot somewhere.
The absolute path to the /db is: d:\domains\mydomain.com\db Hope that helps, post back if you have any further queries. Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|