problem in code
-
hi when i run this code this generate error why? objCommand.Parameters.Add("@nopersoneli", SqlDbType.int).Value =int.parse(txtNoPersoneli.text); thanks a lot
-
hi when i run this code this generate error why? objCommand.Parameters.Add("@nopersoneli", SqlDbType.int).Value =int.parse(txtNoPersoneli.text); thanks a lot
1. What's the error you're getting 2. Should that be @"nopersoneli" ? 3. Should that be txtNoPersoneli.Text ? 4. Does txtNoPersoneli.Text definately contain a valid integer? 4b. Consider getting the integer value before this line by using int.TryParse method.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog) -
hi when i run this code this generate error why? objCommand.Parameters.Add("@nopersoneli", SqlDbType.int).Value =int.parse(txtNoPersoneli.text); thanks a lot
Firstly "problem in code" is as usefull as BLAH for a subject line! Secondly give us more detail, what exception is thrown? by the looks of things you need to do this...
objCommand.Parameters.AddWithValue("@nopersoneli", Int32.parse(txtNoPersoneli.Text));
or
objCommand.Parameters.Add("@nopersoneli", SqlDbType.Int);
objCommand.Parameters["@nopersoneli"].Value = Int32.parse(txtNoPersoneli.Text);Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
1. What's the error you're getting 2. Should that be @"nopersoneli" ? 3. Should that be txtNoPersoneli.Text ? 4. Does txtNoPersoneli.Text definately contain a valid integer? 4b. Consider getting the integer value before this line by using int.TryParse method.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog)DaveyM69 wrote:
2. Should that be @"nopersoneli" ?
it seems hes trying to execute a SQL Stored Procedure using SqlCommand... see my reply
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
Firstly "problem in code" is as usefull as BLAH for a subject line! Secondly give us more detail, what exception is thrown? by the looks of things you need to do this...
objCommand.Parameters.AddWithValue("@nopersoneli", Int32.parse(txtNoPersoneli.Text));
or
objCommand.Parameters.Add("@nopersoneli", SqlDbType.Int);
objCommand.Parameters["@nopersoneli"].Value = Int32.parse(txtNoPersoneli.Text);Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111Harvey Saayman wrote:
by the looks of things you need to do this...
His code 'structure' is actually correctly and will do the same as both your examples. Note: the Add method returns a IDBParameter.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)
((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x)) -
DaveyM69 wrote:
2. Should that be @"nopersoneli" ?
it seems hes trying to execute a SQL Stored Procedure using SqlCommand... see my reply
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111Yeah - just saw the 'crapiness' of the question and jumped on the obvious without too much thought. I never even looked at the beginning of the statement - the possibilities I spotted from briefly scanning just one line of code made me close my eyes!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog) -
Harvey Saayman wrote:
by the looks of things you need to do this...
His code 'structure' is actually correctly and will do the same as both your examples. Note: the Add method returns a IDBParameter.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)
((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))leppie wrote:
is actually correctly
[joke] Don't let Dalek Dave see that, you'll definitively get a English lesson ;P [/joke]
leppie wrote:
the Add method returns a IDBParameter.
I didn't even notice that! The examples i gave is how i use the SqlCommand(or used, im a Linq fan boy now!), the latter of the two is used for DateTime parameters to ensure that the data gets to the db in the correct format.
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
hi when i run this code this generate error why? objCommand.Parameters.Add("@nopersoneli", SqlDbType.int).Value =int.parse(txtNoPersoneli.text); thanks a lot
objCommand.Parameters.Add("@nopersoneli", SqlDbType.int).Value =
convert.Toint32(txtNoPersoneli.text);if that doesn´t work is because "txtNoPersoneli.text" cannot be converted to a int value, or "@nopersoneli" is not int. listen, there is not a reason for that not work :-O
nelsonpaixao@yahoo.com.br trying to help & get help