Microsoft
Software
Hardware
Network
Question : C# Database connection query
Please find below my coding
OleDbConnection aConnection = new OleDbConnection("Provider=
Microsoft.
Jet.OLEDB.
4.0;Data Source=C:\\Users\\test1\De
sktop\\Pro
jects\\Pay
roll\\Inde
x\\Payroll
DB.mdb;Per
sist Security Info=True;Jet OLEDB:Database Password=123456");
aConnection.Open();
OleDbCommand cmd = aConnection.CreateCommand(
);
cmd.Parameters.Add("@Emplo
yeeNumber"
, OleDbType.VarChar).Value = txtEmpNumber.Text;
cmd.Parameters.Add("@Title
", OleDbType.VarChar).Value = cmbTitle.Text;
cmd.Parameters.Add("@First
Name", OleDbType.VarChar).Value = txtFirstName.Text;
cmd.Parameters.Add("@Middl
eName", OleDbType.VarChar).Value = txtMName.Text;
cmd.Parameters.Add("@Surna
me", OleDbType.VarChar).Value = txtSurname.Text;
cmd.Parameters.Add("@Addre
ss1", OleDbType.VarChar).Value = txtAddress1.Text;
cmd.Parameters.Add("@Addre
ss2", OleDbType.VarChar).Value = txtAddress2.Text;
cmd.Parameters.Add("@HomeT
elephone",
OleDbType.VarChar).Value = txtHomeTelephone.Text;
cmd.Parameters.Add("@Email
", OleDbType.VarChar).Value = txtEmail.Text;
cmd.Parameters.Add("@Exten
sionNumber
", OleDbType.VarChar).Value = txtExNumber.Text;
cmd.Parameters.Add("@Sex",
OleDbType.VarChar).Value = txtmale.Text;
cmd.Parameters.Add("@Note"
, OleDbType.LongVarChar).Val
ue = txtNote.Text;
cmd.CommandText = "insert into Employees (EmployeeID,Tittle,FirstNa
me,MiddleN
ame,Surnam
e,Address1
,Address2,
HomeTeleph
one,Email,
ExtensionN
umber,Sex,
Username,N
ote)"
+ "values(@EmployeeNumber,@T
itle,@Firs
tName,@Mid
dleName,@S
urname,@Ad
dress1,@Ad
dress2,@Ho
meTelephon
e,@Email,@
ExtensionN
umber,@Sex
,'test',@N
ote)";
cmd.ExecuteNonQuery();
aConnection.Close();
Its showing Error called "Syntax error in INSERT INTO statement"
But i can't find any error. all the Data type are Text and only Note field is Memo data type.
Can any one help me to solve above issue.thx
Answer : C# Database connection query
Actually, on the print on line 39, it should probably just be
print @err if @err;
since I never stripped the newlines from the output (to do that you can just add to line 37 "my @err = map { chomp; $_ } grep ...").
Random Solutions
SNAPVIEW.OCX
endian
Loading OS in Dell Power edge 2500
ASP.NET 2.0 Warning. Event ID 1309 Source ASP.NET.0.50727.0
Focus with copying filtered data in an async call
How do i add a link to a favorite in outlook that will open the website within outlook?
Adding Roles to Roles In Custom Membership Provider - A Better Way ? C#, SQL, Oracle, ASP.NET
Powerpoint 2003 - in Vista -
Wordpress Search Feature Not Working
Excel VBA code to automatically set a Pivot Table filter on 2 specific values in a field