Hi i got a big problem and don't know how to solve it...
i have an access DB and try to insert a new record!
Fild1: ID - Numeric - PrimaryKey
Fild2: User - Text
//---My ConnectionStrin g----------------------------------
Application["OleConStr"]
= "Provider=Micro soft.Jet.OLEDB. 4.0;Mode=Share Deny None;"
+ @"Data Source=C:\db\ja z.mdb";
//---My Code for Select----------------------------------
//---(works great)---------------------------------------
OleDbCommand cmdS = new OleDbCommand("S elect *
from jaz_test", this.con);
OleDbDataReader rd = cmdS.ExecuteRea der();
while( rd.Read() )
Response.Write( rd["ID"].ToString() + "-" +
rd["User"].ToString());
rd.Close();
cmdS.Dispose();
//RESULT = 1-Webmaster
//RESULT = 2-Webmaster II
//---My Code for Insert (Exception raises)--------------
OleDbCommand cmdI = new OleDbCommand("I NSERT INTO
jaz_test(ID, User) VALUES(3, 'UserX')", this.con);
cmdI.ExecuteNon Query();
cmdI.Dispose();
//---My Problem!----------------------------------
cmdI.ExecuteNon Query() throws Exception "Syntax error in
INSERT INTO statement."
WHERE is the Error?. SQL-Insert statement must be OK! when
i execute it in Access itself, it works great! When i
execute it by VB6 it works great! When i execute it in C++
it works great! BUT NOT IN DOTNET with OleProvider!
What is the problem...?
Thanx for every hint!
Jazper 5 4435
"Jazper" <j.***@bluewin. ch> wrote in message
news:03******** *************** *****@phx.gbl.. . Hi i got a big problem and don't know how to solve it... //---My Code for Insert (Exception raises)-------------- OleDbCommand cmdI = new OleDbCommand("I NSERT INTO jaz_test(ID, User) VALUES(3, 'UserX')", this.con);
I'm guessing a little here, but are you sure you can insert into an
Autonumber column? Does this work?
INSERT INTO jaz_test(User) VALUES('UserX')
then try a
SELECT @@IDENTITY
to get the newly created autonum?
HTH
Tobin Harris
I think i found the error
User is a Access Reserved Word. When i do the sql like
this:
INSERT INTO jaz_test([ID], [User]) VALUES(3, 'UserX')"
then it works...
but why? why can execute the query-editor of access the
query and Dotnet not???
is there a list of reserved words like "User"?
Regards, Jazper
Hi Tobin
No it did not work. Also with Autocolumn. But i think i
found the error..
User is a Access Reserved Word. When i do the sql like
this:
INSERT INTO jaz_test([ID], [User]) VALUES(3, 'UserX')"
then it works...
but why? why can execute the query-editor of access the
query and Dotnet not???
is there a list of reserved words like "User"?
Regards, Jazper -----Original Message----- "Jazper" <j.***@bluewin. ch> wrote in message news:03******* *************** ******@phx.gbl. .. Hi i got a big problem and don't know how to solve it... //---My Code for Insert (Exception raises)-------------- OleDbCommand cmdI = new OleDbCommand("I NSERT INTO jaz_test(ID, User) VALUES(3, 'UserX')", this.con); I'm guessing a little here, but are you sure you can
insert into anAutonumber column? Does this work?
INSERT INTO jaz_test(User) VALUES('UserX')
then try a
SELECT @@IDENTITY
to get the newly created autonum?
HTH
Tobin Harris
.
Jazper,
Apparently one of the words "ID" or "User" is reserved, and you need to
use the bracket notation to escape it so that it can be interpreted as a
column name and not a reserved word.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com
"Jazper" <j.***@bluewin. ch> wrote in message
news:0c******** *************** *****@phx.gbl.. . Hi Tobin
No it did not work. Also with Autocolumn. But i think i found the error..
User is a Access Reserved Word. When i do the sql like this: INSERT INTO jaz_test([ID], [User]) VALUES(3, 'UserX')" then it works...
but why? why can execute the query-editor of access the query and Dotnet not???
is there a list of reserved words like "User"?
Regards, Jazper
-----Original Message----- "Jazper" <j.***@bluewin. ch> wrote in message news:03******* *************** ******@phx.gbl. .. Hi i got a big problem and don't know how to solve it... //---My Code for Insert (Exception raises)-------------- OleDbCommand cmdI = new OleDbCommand("I NSERT INTO jaz_test(ID, User) VALUES(3, 'UserX')", this.con);
I'm guessing a little here, but are you sure you can insert into anAutonumber column? Does this work?
INSERT INTO jaz_test(User) VALUES('UserX')
then try a
SELECT @@IDENTITY
to get the newly created autonum?
HTH
Tobin Harris
.
Once I had this problem. I finally determined that the reserved word was
not in Access, but in the SQL. "User" is reserved in SQL - So, the Access
SQL editor maybe is not fully compliant, or the OLEDB pass through chokes.
One place to find the SQL reserved words is: http://www.jsoftware.com/books/help/...rved_words.htm
UnDo my email.
"Jazper" <j.***@bluewin. ch> wrote in message
news:0c******** *************** *****@phx.gbl.. . I think i found the error User is a Access Reserved Word. When i do the sql like this: INSERT INTO jaz_test([ID], [User]) VALUES(3, 'UserX')" then it works...
but why? why can execute the query-editor of access the query and Dotnet not???
is there a list of reserved words like "User"?
Regards, Jazper This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Charlie Williams |
last post by:
I am having difficulty performing updates and deletions
on an Access database using the Update() method of the
OleDBDataAdapter. I can insert rows without a problem,
but I get a concurrency exception when trying to update
or delete.
I am quite sure that no concurrency conflicts actually
exist. Is there a reason why the data adapter I am using
may have a different row version that the database that
it got its data from?
|
by: Douglas Peterson |
last post by:
Take a look at this code, it looks funny as its written to be as short as
possible:
-- code --
struct Base
{
~Base() { *((char*)0) = 0; }
};
struct Derived : public Base
|
by: guy |
last post by:
i have a method which throws an exception. the thing i dont understand is
that the only change between the two versions is a line of code AFTER the one
that
throws the exception - see code below
the only difference between the il BEFORE the line throwing the exception is
a BR.S as opposed to BR, due to the length of the branch required, which
makes sense.
anyone know what is going on?
|
by: maricel |
last post by:
I have the following base table structure - DDL:
CREATE TABLE "ADMINISTRATOR"."T1" (
"C1" INTEGER NOT NULL )
IN "TEST_TS" ;
ALTER TABLE "ADMINISTRATOR"."T1"
ADD PRIMARY KEY
|
by: Aren Cambre |
last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's
BodyFormat = MailFormat.Html? I've searched all over the place and
cannot find a solution anywhere. I am running this on Windows XP SP2,
and IIS's SMTP and WWW servers are installed.
Here is the error trace:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an...
| |
by: nunya5200-bidness |
last post by:
I hope someone may have some insight to this issue...
I would like to know how to properly implement exception handling using
the ObjectDataSource control.
Specfically, I am doing an insert using an object that calls a web
service to accomplish this. The service returns a message to the
Insert method that indicates that the insert can't be accomplished
because it is trying to insert a duplicate key value. So, I simply
want to raise...
|
by: James Cooke |
last post by:
Hi all,
I want to catch a duplicate key exception. I do not want to provide that
verbose message from the MSSQL server - I would put a user friendly message
out, like
"The item you have added already exists in the database. Please change
the description and try to save again."
instead of
|
by: Ron |
last post by:
my application is throwing an exception error when closing
if I run a procedure in the app. I can't even trap the
error with try/catch ex As Exception. Is there a way to
completely shut down the app through code? I am using
End
for now. Is there a way I can suppress this exception
message? The app gets invoked programmatically on a
schedule. So no one would be around to click off the
|
by: Frawls |
last post by:
Hi
I Am am having problems with a stored Procedure that i wrote.
Basically whats happening is that the Stored procedure Runs fine when i
EXECUTE it in SQL Query analyzer.
But when i debug through the application in Visual Studio .NET 2003 the
application an exception when it executes the query.
|
by: mathieu |
last post by:
Hi there,
I'd like to know if there is a general answer to the following
question: when making a public interface that access a container
should the function throw an exception when the element is not found ?
Otherwise I need two functions: a Find and a Get function which put
the burden on the application programmer to always call Find before
Get.
The other alternative would be to return some kind of sentinel (like
std::set<>::end()...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |