my insert statement got no error but when i check my table the values were not inserted actually.. what maybe the problem?what's the statement? post it here. also post the table DDL.|||my insert statement got no error but when i check my table the values were not inserted actually.. what maybe the problem?I suspect that something didn't work as you expected.
As jezemine suggested, we could help a lot more if you posted the DDL to create the table and the DML that has you puzzled.
-PatP|||my DDL is not hard coded. i have 5 columns in my Cust table(ID, PW, Name, Contact, Add) and the data types are all varchar just having different sizes. the password(PW) is auto generated in my code so i allow nulls for this just for the mean time.
the second problem i encounter is that it has error about the violation of primary key. how can i check that if i can't see the values i inserted in the table? and besides, I'm sure that I'm not entering duplicate primary keys but the error is still the same.
additionally, if you can also help... the speed of my application is very slow. that's only my code and it's responding slooowly... i can't imagine how it will run if i already have a lot of codes.
cmd.CommandText = "INSERT INTO Cust(ID, Name, Contact, Add) VALUES('@.ID','@.Name','@.Contact','@.Add')"; cmd.Parameters.Add("@.ID",SqlDbType.VarChar).Value=textBoxID.Text; cmd.Parameters.Add("@.Name",SqlDbType.VarChar).Value=textBoxName.Text; cmd.Parameters.Add("@.Contact",SqlDbType.VarChar).Value=textBoxContact.Text; cmd.Parameters.Add("@.Add",SqlDbType.VarChar).Value=textBoxAdd.Text;|||you want to remove the single quotes around the parameters:
INSERT INTO Cust(ID, Name, Contact, Add)
VALUES(@.ID,@.Name,@.Contact,@.Add)
very likely, the reason you are seeing pk violations is because you kept trying to insert the value '@.ID' into the pk column.
You might want to (re)read the examples here:
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx|||it has no errors now but still, i can't see in my table the values i inserted. no changes|||Why don't you use stored procedures?|||when you check to see if the values are there, are you sure you are looking at the same database/table that your app is inserting to?
what method are you using to verify the values are there? SSMS, QA, or what? what query are you issuing?|||Why don't you use stored procedures?
Because he/she is not taking the time to read the manual or even check help. When people refer him/her to sites with information, he/she ignores it and continues to ask the same question.
Looking for quick answers and other people to solve your SQL problems for you is not going to teach you anything. Reading the manual or actually bothering to read what people are sending you is also important.|||how sure are you that i didn't read and tried those links? you don't know how i take time reading related articles just to answer my question. if you have nothing to say good, then better fall silent. I'm not forcing everyone here to answer my question especially you! besides, there's a lot of forums that can help me... more patient! I can't blame myself for being slow if you think so, because I'm just new. Don't you realize that you just post here in my thread just to say that.. well, thank you for having time insulting me.|||Your welcome.
I am sure you'll have better luck with those patient forums.
Godspeed.|||my insert statement got no error but when i check my table the values were not inserted actually.. what maybe the problem?
First off, chill
Second, do you think this post helps us figure out what the problem is?
Third, why don't you use stored procedures?|||my insert statement got no error but when i check my table the values were not inserted actually.. what maybe the problem?
the second problem i encounter is that it has error about the violation of primary key.
Care to clarify?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment