473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Inserting Values to Database

66
Front end: Asp.net
Code: C#
Backend:Msaccess

i am doing project on loan, i have to insert the customer values to the database, its showing errors in cmd.executenonquery,


public partial class _Default : System.Web.UI.Page
{
OleDbConnection con;
OleDbCommand cmd;

protected void Page_Load(object sender, EventArgs e)
{
con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; user id= Admin ; password=; Data Source=D:\\Webloanmonitor\\loan.mdb");

}
protected void Button1_Click(object sender, EventArgs e)
{
int i;
string str;
str = "insert into LoanApplication values('" +txtfullname+ "','" +txtfather+ "','" +txtdob+ "','" +txtage+ "','" +RadioButtonList1+ "','" +txteducation+ "','" +ddlistmartial+ "','" + txtmobile + "','" +txtphone+ "','" +txtemail+ "','" +txtresidential+ "','" +txtpermanent+ "')";
cmd = new OleDbCommand(str,con);
try
{
con.Open();
i = cmd.ExecuteNonQuery();
con.Close();
if (i > 0)
{
Response.Redirect("EmploymentDetails.aspx");
}
}
catch (Exception ex)
{
Response.Write("error" + ex);
}

}
}

this is my code , please help me;
i also tried this
insert into LoanApplication(fullname,father,dob.......)Values( '"+txtfullname+'",...........)
Apr 27 '08 #1
4 1343
deric
92
What is the error message?
Try to transfer this line: cmd = new OleDbCommand(str,con);
after the line con.Open();

By the way, use CODE tags around your code. Please read the guidelines on the right.. Thanks.
Apr 27 '08 #2
rekhasc
66
hi...
the error is data type mismatch



Please Enter ProperlySystem.Data.OleDb.OleDbException: Data type mismatch in criteria expression. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at _Default.Button1_Click(Object sender, EventArgs e) in d:\Webloanmonitor\Default.aspx.cs:line 32

here i am attaching my proj, this code is in default.aspx.cs
Attached Files
File Type: zip Webloanmonitor.zip (20.7 KB, 59 views)
Apr 27 '08 #3
rekhasc
66
hi..
thanx for your reply...
i corrected that error but its showing new errors

ERROR: OVERFLOW at

Please Enter Properly::System.Data.OleDb.OleDbException: Overflow at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at _Default.Button1_Click(Object sender, EventArgs e) in d:\Webloanmonitor\Default.aspx.cs:line 31
Attached Files
File Type: zip Webloanmonitor.zip (20.5 KB, 78 views)
Apr 27 '08 #4
deric
92
It seems that some of the values that you provided in your insert statement exceed the allowable value or range of the datatype of your table's column.

Try to do the following:
1. Step trace your code if the values in the insert statement is correct. You can Response.Write(str); to display the final value of str, which is holding your insert statement.

2. Place the name of the columns on your insert.
Like, "Insert Into Table (column1) Values (value1)".
With this, there will be consistency in your code and it will be easier to debug or maintain.

3. For number values, try to not enclose it with single quotes.
Like, instead of "Insert Into Table (numberColumn) Values ('100')", use "Insert Into Table (numberColumn) Values (100)"


Try that and let me know what happens.
Apr 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
2
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it works perfectly: string insertQuery = "INSERT into...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
0
by: gp | last post by:
I am and have been using PDO for about a year now...and have finally gotten around to solving the "DB NULL value" issues I ran into early on... I am looking for suggestions and techniques to...
0
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help....
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
6
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
agi2029
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 project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.