Operation must use an updateable query

  • Thread starter Thread starter Ashim Akbari
  • Start date Start date
A

Ashim Akbari

I start ASP.net
i have sample of Sams book
it's Update SQL. but i got this ERR

Operation must use an updateable query
ERR In Line 42: nRowsAffected = cmd.ExecuteNonQuery(); !!!!!!!!!!!
Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.


i tried my computer and in my Host !!!!!!!!
it's very simple Source:

-----------------------------------------------------------
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=C:\\Program Files\\Microsoft Office\\" +
"Office\\Samples\\Northwind.mdb;" + "User ID=;Password=;");

con.Open();

OleDbCommand cmd = new OleDbCommand("Update Products Set UnitPrice = " +
Price.Text + " where ProductName = '" + Name.Text + "'", con);
int nRowsAffected = 0;

nRowsAffected = cmd.ExecuteNonQuery();

con.Close();
 
Hi Ashim,

Put table and field names of sql statememtn into square brackets.
 
i tried i both case
Update [Products] Set [Products].[UnitPrice] = 2 where
[Products].[ProductName] = 'aa'
AND
Update [Products] Set [UnitPrice] = 2 where [ProductName] = 'aa'
but same result!!!!!!!!!!! :(


Miha Markic said:
Hi Ashim,

Put table and field names of sql statememtn into square brackets.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ashim Akbari said:
I start ASP.net
i have sample of Sams book
it's Update SQL. but i got this ERR

Operation must use an updateable query
ERR In Line 42: nRowsAffected = cmd.ExecuteNonQuery(); !!!!!!!!!!!
Exception Details: System.Data.OleDb.OleDbException: Operation must use
an updateable query.


i tried my computer and in my Host !!!!!!!!
it's very simple Source:

-----------------------------------------------------------
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=C:\\Program Files\\Microsoft Office\\" +
"Office\\Samples\\Northwind.mdb;" + "User ID=;Password=;");

con.Open();

OleDbCommand cmd = new OleDbCommand("Update Products Set UnitPrice = " +
Price.Text + " where ProductName = '" + Name.Text + "'", con);
int nRowsAffected = 0;

nRowsAffected = cmd.ExecuteNonQuery();

con.Close();
 
U¿ytkownik "Ashim Akbari said:
I start ASP.net
i have sample of Sams book
it's Update SQL. but i got this ERR

Operation must use an updateable query
ERR In Line 42: nRowsAffected = cmd.ExecuteNonQuery(); !!!!!!!!!!!
Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.


i tried my computer and in my Host !!!!!!!!
it's very simple Source:

-----------------------------------------------------------
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=C:\\Program Files\\Microsoft Office\\" +
"Office\\Samples\\Northwind.mdb;" + "User ID=;Password=;");

I suppose that user running your program (probably ASPNET) opens the file
C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb in readonly
mode.
Regards,
Grzegorz
 
Hi Ashim,

Other than this, make sure that aspnet local windows account has enough
privileges to your mdb file.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ashim Akbari said:
i tried i both case
Update [Products] Set [Products].[UnitPrice] = 2 where
[Products].[ProductName] = 'aa'
AND
Update [Products] Set [UnitPrice] = 2 where [ProductName] = 'aa'
but same result!!!!!!!!!!! :(


Miha Markic said:
Hi Ashim,

Put table and field names of sql statememtn into square brackets.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ashim Akbari said:
I start ASP.net
i have sample of Sams book
it's Update SQL. but i got this ERR

Operation must use an updateable query
ERR In Line 42: nRowsAffected = cmd.ExecuteNonQuery(); !!!!!!!!!!!
Exception Details: System.Data.OleDb.OleDbException: Operation must use
an updateable query.


i tried my computer and in my Host !!!!!!!!
it's very simple Source:

-----------------------------------------------------------
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=C:\\Program Files\\Microsoft Office\\" +
"Office\\Samples\\Northwind.mdb;" + "User ID=;Password=;");

con.Open();

OleDbCommand cmd = new OleDbCommand("Update Products Set UnitPrice = " +
Price.Text + " where ProductName = '" + Name.Text + "'", con);
int nRowsAffected = 0;

nRowsAffected = cmd.ExecuteNonQuery();

con.Close();
 
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=154273

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


Ashim Akbari said:
i tried i both case
Update [Products] Set [Products].[UnitPrice] = 2 where
[Products].[ProductName] = 'aa'
AND
Update [Products] Set [UnitPrice] = 2 where [ProductName] = 'aa'
but same result!!!!!!!!!!! :(


Miha Markic said:
Hi Ashim,

Put table and field names of sql statememtn into square brackets.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ashim Akbari said:
I start ASP.net
i have sample of Sams book
it's Update SQL. but i got this ERR

Operation must use an updateable query
ERR In Line 42: nRowsAffected = cmd.ExecuteNonQuery(); !!!!!!!!!!!
Exception Details: System.Data.OleDb.OleDbException: Operation must use
an updateable query.


i tried my computer and in my Host !!!!!!!!
it's very simple Source:

-----------------------------------------------------------
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=C:\\Program Files\\Microsoft Office\\" +
"Office\\Samples\\Northwind.mdb;" + "User ID=;Password=;");

con.Open();

OleDbCommand cmd = new OleDbCommand("Update Products Set UnitPrice = " +
Price.Text + " where ProductName = '" + Name.Text + "'", con);
int nRowsAffected = 0;

nRowsAffected = cmd.ExecuteNonQuery();

con.Close();
 
Back
Top