Inser into mdb from asp.net page

G

Guest

Hello,
I can't get info from my web form into my Access database.
The connection works.
I've tried a command with CommandText = "Insert Into..."
Error! "You have to have a query that allows changes..."
With DataAdapter and Dataset I don't get any errors, but
the record isn't added either.
Sequrity issues?

Grateful for any tip,
Kristian Karre
 
S

Stuart A Hill

Hi Kristian,

Do you have the full error string? That would be helpful.

My first recommendation would be for you to check the properties of the mdb.
Is it marked as read-only? If it is, you will also need to recreate your
connection string, as it will have stored a mode attribute set to 'Read',
which should be set 'Share Deny None'.

Try this and see if it helps! If not, post a bit more information.

Regards,

Stuart
MCSD, MCT
 
G

Guest

Hi Stuart,
I think you're on to something.
I CAN enter a new record when connecting to a mdb in a "normal" folder, but
not to the one on the website on IIS.
I'm using a web hotel and don't know how to get the complete error message,
but if you could tell me how to adjust the connectionstring so "Share Deny
none" is included that might work.

TiA, Kristian
 
G

Guest

I had the similar problem before. What I did is set Everyone has "full
control" access right on mdb file. And then it works fine. It sounds weird.
But, it works, I don't know why.
 
S

Stuart A Hill

Hi Kristian,

Are you using Visual Studio? The quickest way to check the connection string
is to create a data link in the Server Explorer window to your access
database (Right-Click the data connections folder and select 'Add
Connection'), and then drag the database from the Server Explorer to a web
form. This will create a connection object, which will contain all the
connection string attributes. However, in case you are not using Visual
Studio, and if not why not ;-) I have done this for you below: (You are
looking for the Mode attribute)

ReadOnly Connection String:

Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
OLEDB:Database Locking Mode=0;Jet OLEDB:Database Password=;Data
Source="C:\trader.mdb";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global
Bulk Transactions=1;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System
database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Read;Jet OLEDB:New
Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't
Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica
Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False

ReadWrite Connection String:

Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data
Source="C:\trader.mdb";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global
Bulk Transactions=1;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System
database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet
OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet
OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica
Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False

If this doesn't work then the next thing to look at would be a permissions
setting on the folder itself.

Regards,

Stuart
MCSD, MCT
 
G

Guest

I'm trying out at my local laptop that's got IIS installed.
I'm using VS .NET, created OleDbConnection object via drag and drop
(Mode=Share Deny None)
The Folder is set to allow anything, the mdb is not write protected...
Doesn't the code (or sap .net) have the same rights as I do?

This was way more tricky than I thought!
Any more ideas?
Hopeful,
Kristian
 
J

Joe Fallon

I have seen that error before.
It can come from a query that has bad syntax.

Please post your code for the query (including parameters.)
BTW - Access does not use named parameters.
When you build them up, you have to apply them in the same sequence.
If they are out of order you could get this error.
 
G

Guest

The connection - seems to work is this:
cnDb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\SLSwebbApp\db_Axs\sls.mdb;Persist Security
Info=False"

The insert command is this:
cmdIns.CommandText = _
"INSERT INTO Personer ( Företag, FNamn, ENamn, Adressrad1,
Adressrad2, Pnr, Ort, Tfn1, Tfn2, Epost,Medlem, Medlemsnr, Instruktör, Aktiv,
Livinfo) Values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"


The parameters read as follows:

cmdIns.Parameters.Add("?Företag", OleDb.OleDbType.VarChar,
80).Value = Me.txtFtag.Text
cmdIns.Parameters.Add("?FNamn", OleDb.OleDbType.VarChar,
80).Value = Me.txtFNamn.Text
cmdIns.Parameters.Add("?ENamn", OleDb.OleDbType.VarChar,
80).Value = Me.txtENamn.Text
cmdIns.Parameters.Add("?Adressrad1", OleDb.OleDbType.VarChar,
80).Value = Me.txtAdr1.Text
cmdIns.Parameters.Add("?Adressrad2", OleDb.OleDbType.VarChar,
80).Value = Me.txtAdr2.Text
cmdIns.Parameters.Add("?Pnr", OleDb.OleDbType.VarChar, 80).Value
= Me.txtPnr.Text
cmdIns.Parameters.Add("?Ort", OleDb.OleDbType.VarChar, 80).Value
= Me.txtOrt.Text
cmdIns.Parameters.Add("?Tfn1", OleDb.OleDbType.VarChar,
80).Value = Me.txtTfn1.Text
cmdIns.Parameters.Add("?Tfn2", OleDb.OleDbType.VarChar,
80).Value = Me.txtTfn2.Text
cmdIns.Parameters.Add("?Epost", OleDb.OleDbType.VarChar,
80).Value = Me.txtEpost.Text
cmdIns.Parameters.Add("?Medlem", OleDb.OleDbType.Boolean).Value
= Me.chkMedlem.Checked
cmdIns.Parameters.Add("?Epost", OleDb.OleDbType.VarChar,
80).Value = Me.txtMedlNr.Text
cmdIns.Parameters.Add("?Instruktör",
OleDb.OleDbType.Boolean).Value = Me.chkInstr.Checked
cmdIns.Parameters.Add("?Aktiv", OleDb.OleDbType.Boolean).Value =
Me.chkAktiv.Checked
cmdIns.Parameters.Add("?Livinfo", OleDb.OleDbType.Boolean).Value
= Me.chkVillHaInfo.Checked
cmdIns.Connection = cnDb
AntalInfogade = cmdIns.ExecuteNonQuery()

Grateful for anything that could take me closer to a solution...
Kristian
 
G

Guest

I believe it has to do with my connections.
I can pull info from the db, put cannot add records, nor update.
Sholud I use Ole Db provider for ODBC or "simple provider or OLE DB-provider
if I want to access a mdb with full rights?
ShareDenyNone seems hard to acccomplish...
And this is only localy on my "web server".
What's to be expected on the Web Hotel?
He - EEELP!
Kristian
 
M

Michal Boleslav Mechura

I was facing a similar problem recently, and I found out that the account
the .NET Framework uses to execute ASP.NET applications didn't have the
correct rights to write to the MDB file. It's that simple!

The account under which your ASP.NET applications run is called "ASPNET" and
you need to grant it the necessary rights. I did it on my own machine by
making the account a member of the Administrators group, and I asked my "web
hotel" to create a special directory on my website and give the account
write access to it.

I don't know if this is the same issue as the person who asked the question
is facing, but it could be. Oh and just one more thing, when you add an
account to a group in Windows, you usually need to reboot the damn thing for
changes to take effect.

Hope this helps,
Michal

--
Michal Boleslav Mechura
(e-mail address removed)

Kristian said:
I believe it has to do with my connections.
I can pull info from the db, put cannot add records, nor update.
Sholud I use Ole Db provider for ODBC or "simple provider or OLE
DB-provider
if I want to access a mdb with full rights?
ShareDenyNone seems hard to acccomplish...
And this is only localy on my "web server".
What's to be expected on the Web Hotel?
He - EEELP!
Kristian
[...]
 
G

Guest

Yes! This was it!
A million thanks!
Kristian

Michal Boleslav Mechura said:
I was facing a similar problem recently, and I found out that the account
the .NET Framework uses to execute ASP.NET applications didn't have the
correct rights to write to the MDB file. It's that simple!

The account under which your ASP.NET applications run is called "ASPNET" and
you need to grant it the necessary rights. I did it on my own machine by
making the account a member of the Administrators group, and I asked my "web
hotel" to create a special directory on my website and give the account
write access to it.

I don't know if this is the same issue as the person who asked the question
is facing, but it could be. Oh and just one more thing, when you add an
account to a group in Windows, you usually need to reboot the damn thing for
changes to take effect.

Hope this helps,
Michal

--
Michal Boleslav Mechura
(e-mail address removed)

Kristian said:
I believe it has to do with my connections.
I can pull info from the db, put cannot add records, nor update.
Sholud I use Ole Db provider for ODBC or "simple provider or OLE
DB-provider
if I want to access a mdb with full rights?
ShareDenyNone seems hard to acccomplish...
And this is only localy on my "web server".
What's to be expected on the Web Hotel?
He - EEELP!
Kristian
[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top