Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir, I am getting problem when I enter data at text fields and it give the problem of ISAM. Can you give me the solution of it I am sending the code tell me?

C#
public partial class custmer_module_CustmerReg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;datasource=c:\\realtionship\\crm.mdb";
            con.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandText = "insert into custmer detail value (" + txtcustname.Text + " " + txtpwd.Text + " " + txtgender.Text + " " + txtage.Text + " " + txtemail.Text + " " + txtaddress.Text + " " + txtphoneno.Text + ")";
            cmd.Connection = con;
            int n = cmd.ExecuteNonQuery();
            if (n == 1)
                lblmsg.Text = "custmer registerd";
            con.Close();
        }

        catch (Exception er )
        {
            lblmsg.Text = er.Message;
        }
    }
}


[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 28-Feb-12 5:57am
v2
Comments
ZurdoDev 28-Feb-12 11:44am    
Is there an error?
Oshtri Deka 28-Feb-12 15:28pm    
Can you post exception message?
I know it's not your question, but why you don't use separate columns for each of above values?
Perhaps there are to much character for that column to handle?

1 solution

Well, all things being equal (which they never really are) I suspect what you might mean is something like the following, though feel free to ignore me if I have it utterly arse-backwards.

SQL
cmd.CommandText = "insert into customer_detail (list_of_matching_columns) values (" + txtcustname.Text + ", " + txtpwd.Text + ", " + txtgender.Text + ", " + txtage.Text + ", " + txtemail.Text + ", " + txtaddress.Text + ", " + txtphoneno.Text + ")";


1: Table names should not have spaces.
2: It is usual, when inserting, to list all of the columns you are matching in your select/values unless the inserted columns exactly match what is already there.
3: I would imagine that each of the fiels matches a field in the table and that you are not trying to concatanate all of them into one field therefore you require commas to separate each field value so that the database knows what they are and where you want them to go.
4: Try to get out of tha habit of using SQL in code: create and use stored procedures and pass parameters.
5: It's 'values' not 'value'.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900