Could Anyone help me!
I'm currenly working on an application which involves SQL
Statements. And my current problem is that when i execute
the SQL statement on MS Access 2003 the Insert Statement
performs fine when i'm using OledbCommand to execute it
there would be an exception raise "Syntax Error insert
into" Why is this so?
Here is a code segment where the error occured:
public string InsertEmployee( Employee NewEmployee)
{
DailyAttendance Config DAConfig = new
DailyAttendance Config();
DataRow DRwork;
OleDbConnection Conn;
OleDbDataAdapte r OleDbAdap= new OleDbDataAdapte r();
OleDbCommand Comm;
Employee Emp = new Employee();
try
{
Conn = DAConfig.MakeCo nnection();
DRwork = NewEmployee.Tab les
[Employee.Employ eeInformationTa ble].Rows[0];
Comm = new OleDbCommand();
Comm.CommandTex t = "insert into
EmployeeInforma tion "
+ "(EmpID,Fname,L name,Mname,gend er,civilstatus, datehired,"
+"BirthDate,Tin Num,SSSNum,PagI bigNum,PhilHeal th,Spousename
,SpouseOccupati on,MaidenName,C itizenship,"
+"bloodtype,tel num,cellnum,ema iladdress,citya ddress,provin
cialaddress,fat hername,fathero ccupation,"
+ "mothername,mot heroccupation,b ankaccount,sick leave,vacat
ionleave,active ,paycode,positi on,"
+ "officeId,Basic pay) " +
"values (" + DRwork[0] + ",'" + DRwork[2] + "','"
+ DRwork[1] + "','" + DRwork[3] + "'," + DRwork[5] + ","
+ DRwork[4] + ",'" + DRwork[6] + "','" + DRwork[7]
+ "','" + DRwork[8] + "','" + DRwork[9] + "','" + DRwork
[10] + "','" + DRwork[11] + "','" + DRwork[12] +"','" +
DRwork[13] + "','" + DRwork[14] + "','" + DRwork[15]
+ "','" + DRwork[16] + "','" + DRwork[17] + "','" + DRwork
[18] + "','" + DRwork[19] + "','" + DRwork[20] + "','" +
DRwork[21] + "','" + DRwork[22] + "','" + DRwork[23]
+ "','" + DRwork[24] + "','" + DRwork[25] + "','" + DRwork
[26] + "'," + DRwork[28] + "," + DRwork[29] + ",1," +
DRwork[32] + ",'" + DRwork[31] + "'," + DRwork[30] + ","
+ DRwork[33] + ")";
Comm.Connection = Conn;
Conn.Open();
OleDbAdap.Inser tCommand = Comm;
OleDbAdap.Updat e
(NewEmployee,Em ployee.Employee InformationTabl e);
return "Success!";
}
catch (OleDbException ex)
{
return ex.Message + " - " + ex.ErrorCode.To String();
}
}
Please Help me on this 2 2692
set a breakpoint on line "Comm.Connectio n=..."
when code stops there, check out in the locals "Comm.CommandTe xt"
copy the SQL statement and try it on a new MSAccess Query.
that way you'll find the error easier
Lennin Arriola
"Christophe r" <ch***@mandaue. tti.com.ph> wrote in message
news:07******** *************** *****@phx.gbl.. . Could Anyone help me!
I'm currenly working on an application which involves SQL Statements. And my current problem is that when i execute the SQL statement on MS Access 2003 the Insert Statement performs fine when i'm using OledbCommand to execute it there would be an exception raise "Syntax Error insert into" Why is this so?
Here is a code segment where the error occured:
public string InsertEmployee( Employee NewEmployee) { DailyAttendance Config DAConfig = new DailyAttendance Config(); DataRow DRwork; OleDbConnection Conn; OleDbDataAdapte r OleDbAdap= new OleDbDataAdapte r(); OleDbCommand Comm; Employee Emp = new Employee(); try { Conn = DAConfig.MakeCo nnection(); DRwork = NewEmployee.Tab les [Employee.Employ eeInformationTa ble].Rows[0]; Comm = new OleDbCommand(); Comm.CommandTex t = "insert into EmployeeInforma tion " + "(EmpID,Fname,L name,Mname,gend er,civilstatus, datehired,"
+"BirthDate,Tin Num,SSSNum,PagI bigNum,PhilHeal th,Spousename ,SpouseOccupati on,MaidenName,C itizenship," +"bloodtype,tel num,cellnum,ema iladdress,citya ddress,provin cialaddress,fat hername,fathero ccupation," + "mothername,mot heroccupation,b ankaccount,sick leave,vacat ionleave,active ,paycode,positi on," + "officeId,Basic pay) " + "values (" + DRwork[0] + ",'" + DRwork[2] + "','" + DRwork[1] + "','" + DRwork[3] + "'," + DRwork[5] + "," + DRwork[4] + ",'" + DRwork[6] + "','" + DRwork[7] + "','" + DRwork[8] + "','" + DRwork[9] + "','" + DRwork [10] + "','" + DRwork[11] + "','" + DRwork[12] +"','" + DRwork[13] + "','" + DRwork[14] + "','" + DRwork[15] + "','" + DRwork[16] + "','" + DRwork[17] + "','" + DRwork [18] + "','" + DRwork[19] + "','" + DRwork[20] + "','" + DRwork[21] + "','" + DRwork[22] + "','" + DRwork[23] + "','" + DRwork[24] + "','" + DRwork[25] + "','" + DRwork [26] + "'," + DRwork[28] + "," + DRwork[29] + ",1," + DRwork[32] + ",'" + DRwork[31] + "'," + DRwork[30] + "," + DRwork[33] + ")"; Comm.Connection = Conn; Conn.Open(); OleDbAdap.Inser tCommand = Comm; OleDbAdap.Updat e (NewEmployee,Em ployee.Employee InformationTabl e); return "Success!"; } catch (OleDbException ex) { return ex.Message + " - " + ex.ErrorCode.To String(); } }
Please Help me on this
Lennin,
I already done that the SQL Statement executed well no problem was
found. i know the statement has the correct syntax. i don't know why
that error came out.
This is just the first time i had this problem since i had program with
net
Thanx
Chris
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eitan |
last post by:
Hello,
I need sample code for using oleDBCommand in ASP (not dotnet), please.
Thanks :)
|
by: Jason Steeves |
last post by:
-Dim cmd As OleDbCommand
-cmd = New OleDbCommand("select * from qmsstats where firstname='jason'",
OleDbConnection1)
-OleDbDataAdapter2.SelectCommand = cmd
-DataGrid1.Visible = True
-OleDbDataAdapter2.Fill(DsQmsStats1)
-DataGrid1.DataBind()
In the above example I need to change 'jason' to a variable. I need the
variable to be pulled from a textbox. IE: txtusername.text. Please advise how
|
by: jerim |
last post by:
Hi
I have the following Problem:
I have an Access DB.
Tablename: Formate;
TableColoumns: ID (=Numeric)
Name (=string)
|
by: Brian |
last post by:
Was browsing around online for code to connect to a database usign ADO
and C#... and i found this very simple but useful reference
(http://www.c-sharpcorner.com/database/db_list.asp)
However, implementing this into my own project does seem to work.
I'm getting an error: 'System.Data.OleDb.OleDbCommand' does not
contain a definition for 'Fill'
Why would this be?
|
by: Adam |
last post by:
Hey guys Im pretty new to this parameterized commands thing and I dont
know why this code isnt working. I have a Connection object set up as
Conn, and a Rec object which is holding my values. This method is inside
a "Class Library" being called from a "Windows Form" if that means anything.
string strCmd = "INSERT INTO Table (Value,Value,Value,Value,Value)
VALUES ('?','?','?','?','?')";
OleDbCommand cmd = new OleDbCommand(strCmd,Conn);...
| |
by: Tom Wild |
last post by:
Hi
I am creating a webform in VB.Net which connects to an Access database.
I can get the webform to connect to the database fine and also to download
data but when I try and update the database by firing off an OleDBCommand I
get the following error:
"Problem firing System.Data.OleDb.OleDbCommand - Operation must use an
updateable query"
|
by: RG |
last post by:
OleDbCommand.Prepare error: Size of parameter (VB.NET 2003)
I need to do a SQL INSERT statement into an Access table, and I’d like to
use the exact technique described in the Help file example for
OleDbCommand.Prepare Method.
When I follow the example exactly I get the unhandled exception error message:
“OleDbCommand.Prepare Method requires all parameters to have an explicitly
set type”.
|
by: Agnes |
last post by:
Dim authConnection As New OleDbConnection("Provider =
VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc")
authConnection.Open()
Dim authCommand As String = "select loginid from coinfo
where loginid = @cocode "
oleCommand.Parameters.Add("@cocode", OleDbType.VarChar,
10).Value = "1001"
or oleCommand.Parameters.Add(new oledbparameter("@cocode",
OleDbType.VarChar, 10)).Value = "1001"
|
by: =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?= |
last post by:
sippyuconn wrote:
The purpose of reusing a command is to set it up with parameters and
everything and then call the Prepare method. Then each time you use the
command you just assign values to the parameters and execute the command.
If you are going to add the parameters each time, there is no reason to
hang on to the command object either, you can just create a new command
object each time.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |