| Probi |
Posted: May 21, 2008 07:36:24 AM |
Total Post: 4
Joined: May, 2008
|
Hello,
I have come accros this problem, altough I have been using this code before
I have an oracle command with 1 parameter
string cmd = " Select value from Database where id = :p1";
OracleCommand command1 = new OracleCommand ( cmd, connection); OracleParameter p1= new OracleParameter ( "p1", OracleType.Varchar, 8);
p1.Direction = ParameterDirection.InputOutput;
OracleDataReader rdr = null;
try { connection.Open();
command.Parameters.Clear();
command.Parameters.Add(p1);
p1.Value = id_1;
command.ExecuteNonQuery();
rdr = command .ExecuteReader();
......
}
the problem I get is in this line p1.Value=id_1;
id_1 is a string of max 8 characters,
and in p1.Value I get just the 1character
any idea why?
thanks Probi
|
|
|
fozturk |
| Posted: May 21, 2008 07:44:46 AM | |
|
Total Post: 69
Joined: Sep, 2007
|
i guess you shall assing the parameter value before you add to the commands parameters,
reverse the order of
"command.Parameters.Add(p1);
p1.Value = id_1;
"
with
"
p1.Value = id_1;
command.Parameters.Add(p1);
"
hope works
|
|
|
|
|
Probi |
| Posted: May 21, 2008 08:43:11 AM | |
|
Total Post: 4
Joined: May, 2008
|
Hello,
I tried your idea
but still no change
to better explain
ex. atring id_1 = " valuse";
after this line
p1.Value = id_1;
id_1 = value and p1.Value = v
so it gets some value just not the whole string
any other ideas?
thanks
Probi
|
|
|
|
|
GOPU |
| Posted: May 22, 2008 06:39:20 AM | |
|
Total Post: 335
Joined: Apr, 2008
|
when you execute this query what the error you are getting ?
|
|
|
|
|
Probi |
| Posted: Jun 18, 2008 11:55:36 AM | |
|
Total Post: 4
Joined: May, 2008
|
Ok,
I´m still with the same problem, but now I have more details
Example: I have a string of 4 characters ( string car = "abcd";)
and I pass it to parameter p1
p1.Value = car;
in the debug I see that car has the value "abcd"
but p1.Value gets only "ab"
I tryed more examples and in every situation it get just half of the string
the parameter is defined as
OracleParameter p1 = new OracleParameter("p1", OracleType.VarChar, 8);
p1.Direction = ParameterDirection.InputOutput;
so it should get all 8 characters
any help is more than wellcomed, Im getting frustrated
Thanks,
Probi
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |