Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am trying to add new elements to my database. I am able to add only add 1 field out of the 3 fields in the database.

Following is the code for my Button Event handler,
protected void Button1_Click(object sender, EventArgs e)
{

QuizUserDetailsDataContext context = new QuizUserDetailsDataContext(ConfigurationManager.ConnectionStrings["krs_projectConnectionString"].ToString());
            krs_userdetail1 krs_user = new krs_userdetail1();
            
            
            krs_user.emailid = EmailText.Text;
            krs_user.uname = TextBox1.Text;
            krs_user.password = TextBox2.Text;

            context.krs_userdetail1s.InsertOnSubmit(krs_user);

          
            context.SubmitChanges();

}


The database structure is as follows,

create table dbo.user_details
( uname varchar(50) not null,
password varchar(50) not null,
emailid varchar(50) not null,
primary key(uname,emailid))

When I add the elements in the DB, and when I check in the database, I can see that only the Password field is having a value, whereas the other 2 fields of the DB are blank...

Can anybody assist me in this regard !!

Many Thanks in Advance...
Posted

1 solution

Set a breakpoint on this line:
context.krs_userdetail1s.InsertOnSubmit(krs_user)


Check the values of the strings you've assigned and see if there's anything in those strings (and the Text properties). This will at least let you isolate the problem.

Cheers.
 
Share this answer
 
Comments
Mukund Kallapur 18-Aug-10 14:54pm    
Thank you. I will try this.
TheyCallMeMrJames 18-Aug-10 14:55pm    
Let me know what happens and if you have strings there.

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