Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server C#4.0
Can anyone help me here please...
 
private void button3_Click(object sender, EventArgs e)
        {
            SqlCeConnection con = new SqlCeConnection();
            con = utility.createconnection("Database1");            
            Database1DataSet1 dsCustomer = new Database1DataSet1();
            SqlCeCommand Query = new SqlCeCommand("INSERT INTO shop_details " +
                                "(shop_name,Name,Address,shop_id) " +
                                "VALUES (@shop_name,@Name,@Address,@shop_id)", con);
 
         
            Query.Parameters.AddWithValue("@shop_name", textBox8.Text);
            Query.Parameters.AddWithValue("@Name", textBox1.Text);            
            Query.Parameters.AddWithValue("@Address", textBox2.Text);
            Query.Parameters.AddWithValue("@shop_id", textBox7.Text);
            Query.ExecuteNonQuery();
            SqlCeDataAdapter sqlceda = new SqlCeDataAdapter(Query);
            sqlceda.Fill(dsCustomer, "shop_details");
         
        }
Posted 19-Jan-13 21:25pm
Comments
OriginalGriff at 20-Jan-13 3:42am
   
Form just that data, no we can't - do you get any errors? How can you tell no data is inserted? Have you checked that the button click event is getting fired?
Member 4464669 at 20-Jan-13 4:06am
   
There was no errors found. When I clicking the button no data inserted into the table. When I debug the code text box values are getting but finally there was no rows inserted into the table.
OriginalGriff at 20-Jan-13 4:51am
   
"There was no errors found"
Compilation or runtime - did you step through in the debugger and check your code and variables at each step?
"no rows inserted into the table"
How do you know? Where did you look for your records, and how? Did you use SSMS? Or your own code?
Member 4464669 at 20-Jan-13 5:29am
   
Compilation - No error
When debugging via runtime at eachstep - all the values are populating in each step.
When I querying into the Database1.sdf (Database) No rows returned.
OriginalGriff at 20-Jan-13 5:50am
   
What query did you use?
BTW: If you use the "Reply" feature instead of "question or comment" this might go quicker - I get an email then, instead of having to remember to check back here and see if there is new info.
Member 4464669 at 20-Jan-13 6:29am
   
select * from shop_details;
OriginalGriff at 20-Jan-13 6:52am
   
Does your createconnection method use a transaction?
Can you show the code for using the select? (Remember, I can't see your screen or access your HDD so you have to "spoon-feed" me to an extent!)
digimanus at 21-Jan-13 7:12am
   
why use a DataAdepter to fill when needing ExecuteNonQuery for an Insert statement? Are all textboxes filled or is NULL the value of any of these parameters.
Faisalabadians at 21-Jan-13 9:32am
   
is con's connection state is opened?

1 solution

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

  Print Answers RSS
0 OriginalGriff 469
1 ChintanShukla 305
2 Sergey Alexandrovich Kryukov 253
3 RyanDev 250
4 Richard Deeming 250
0 Sergey Alexandrovich Kryukov 8,906
1 OriginalGriff 7,601
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,923


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100