PDA

View Full Version : adding new records



Farhad.B.S
دوشنبه 03 شهریور 1382, 15:44 عصر
سلام.
من این سوال رو پرسیده بودم , نمیدونم چرا پاک شده ولی چون به جواب نرسیدم دوباره میپرسم :

من برای اضافه کردن رکورد های جدید از این روش استفاده میکنم :



DataPath = Server.MapPath(".") + "\Database.mdb"
dbConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataPath + ";"
dbCommand.Connection = dbConnection
dbCommand.CommandType = CommandType.Text
SQLCommand = "INSERT INTO MailingList (emailaddress) VALUES ('emailaddress@host.com')"
dbCommand.CommandText = SQLCommand
dbConnection.Open()
dbCommand.ExecuteNonQuery()


ولی این error رو میگیرم :
Operation must use an updateable query

من تو iis به دایرکتوری مجازی که فایل ها + فایل اکسس تو اون قرار داره اجازه read/write رو دادم .

بانک access رو هم اینجا گذاشتم ...

ممنون.

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:36 عصر
ببینید این مشکل شما را حل می کند ؟


String FilePath;
FilePath = Server.MapPath("acess_db.mdb");

// Connect to Database
OleDbConnection cnAccess = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+
"Data Source="+ FilePath );
cnAccess.Open();


//Make the insert statement
string sInsertSQL = "insert into tblEntry values(" +
txtID.Text + "," + txt_Entry_No.Text + ")";

//Make the OleDbCommand object
OleDbCommand cmdInsert = new OleDbCommand(sInsertSQL,cnAccess);

// This not a query so we do not expect any return data so use
// the ExecuteNonQuery method
cmdInsert.ExecuteNonQuery();

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:39 عصر
شما این دیتابیس را با ویژوال بیسیک یعنی ViSData درست کرده اید؟ اگر اینطور است اکسس اکس پی را نصب کنید و با استفاده از آن دیتابیس را به فرمت اکسس 2002 تبدیل کنید. همان ابتدای ورود خودش اینکار را انجام می دهد.

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:42 عصر
ببینید عمو بیلی چی می گه!

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q175/1/68.ASP&NoWebContent=1

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:45 عصر
Ever seen this error "Operation must use an updateable query" when trying to add, update or delete when using ASP and Microsoft Access on your web? How do I get rid of it? Here is your answer... The IUSR_MACHINENAME account which is used by IIS when accessing webpages and directory's has to be able create the .ldb file. This is a file Access creates on the fly when its opened.

Without getting into a full discussion on NT security and all it involves. Just make sure the IUSR_MACHINENAME account has at least change permissions on the particular directory the database resides in so data can be inserted to it.. By default the IUSR_MACHINENAME account is only given Read, Execute permissions. You'll only see this error when using the NTFS file system. This is the most secure file system available on NT. If your unsure how to do this consult your web admin!

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:48 عصر
The most common reason for this problem is that your anonymous IIS account IUSR_<MACHINE> does not have write rights to the MDB file.

Additionally you may also need to grant read and write permissions on the "Temp" folder because the Jet engine might create temporary files in this directory.

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:51 عصر
fix the problem by editing the machine.config file enabling impersonation as directed by the microsoft support site http://support.microsoft.com/default.aspx?scid=kb;en-us;316675

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 18:59 عصر
http://www.banmanpro.com/support/odbc.asp

Vahid_Nasiri
دوشنبه 03 شهریور 1382, 19:01 عصر
کلام آخر! : ( همان مشکل امنیتی و عدم دسترسی و مجوز دهی را دارید...... که قبلا هم گفتم )


Make sure the folder containing the Access DB file has change permissions
for the needed users. Also, set the same permissions for the temporary
directory for the OS (usually C:\winnt\temp).

Farhad.B.S
سه شنبه 04 شهریور 1382, 11:47 صبح
سلام.
اقا وحید خیلی خیلی ممنون . :oops: