
I want to retrieve the same information, based on the same input in Visual Studio Professional 2010, based on the attached code, but with error as atttached:
It is able to go through the code, and show the message box with the word "Connected".
Appreciate any help.

Posted Jul 29, 2013, 12:56 AM EDT
We need to use "?" for the command parameters.
cmd.CommandText = "SELECT VHITNO FROM MWOHED WHERE VHMFNO =?";
cmd.Parameters.AddWithValue("@VHMFNO", MO_No);
Hope this helps TAN and someone !
Posted Jul 28, 2013, 9:32 PM EDT
Try this way.
//Just hardcode the complete query
cmd.CommandText = "SELECT VHITNO FROM MWOHED WHERE VHMFNO ='"+MO_No +"'";
//Later include the single quotes in the query.
cmd.CommandText = "SELECT VHITNO FROM MWOHED WHERE VHMFNO ='"+@VHMFNO +"'";
cmd.Parameters.AddWithValue("@VHMFNO", MO_No);
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 28, 2013, 9:46 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 28, 2013, 9:56 PM EDT
Posted Jul 28, 2013, 10:45 PM EDT
I'm attached the parameter the query + cmd.ExecuteReader() is changed. We will try without commandbehaviour option.
//Just hardcode the complete query
cmd.CommandText = "SELECT VHITNO FROM MWOHED WHERE VHMFNO ='" + MO_No + "'";
//Later include the single quotes in the query.
//cmd.Parameters.AddWithValue("@VHMFNO", MO_No);
//cmd.CommandText = "SELECT VHITNO FROM MWOHED WHERE VHMFNO ='" + @VHMFNO + "'";
con.Open();
MessageBox.Show("Connected");
try
{
OdbcDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
ProductionInfo productioninfo = new ProductionInfo((String)reader["VHITNO"]);
return (productioninfo);
}
else
{
return null;
}
}
finally
{
con.Close();
}
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 28, 2013, 10:55 PM EDT
Posted Jul 28, 2013, 10:57 PM EDT
Schema name added.
cmd.CommandText = "SELECT VHITNO FROM pfods.MWOHED WHERE VHMFNO ='" + MO_No + "'";
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 29, 2013, 12:15 AM EDT
for Oracle's NUMBER, is the C# Datatype Int32?
for Oracle's NUMBER(15,6), is the C# Datatype Int64?
I keep on getting the error message "Error contacting database".
I attached the whole project with the printscreen for the LINQPAD.
Posted Jul 29, 2013, 12:19 AM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 29, 2013, 12:31 AM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Jul 29, 2013, 12:59 AM EDT