
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, 4:56 AM
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 !
TAN WhoAMIPosted Jul 29, 2013, 4:59 AM
TAN WhoAMIPosted Jul 29, 2013, 4:31 AM
Posted Jul 29, 2013, 4:19 AM
TAN WhoAMIPosted Jul 29, 2013, 4:15 AM
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, 2:57 AM
Schema name added.
cmd.CommandText = "SELECT VHITNO FROM pfods.MWOHED WHERE VHMFNO ='" + MO_No + "'";
TAN WhoAMIPosted Jul 29, 2013, 2:55 AM
Posted Jul 29, 2013, 2:45 AM
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 WhoAMIPosted Jul 29, 2013, 1:56 AM
TAN WhoAMIPosted Jul 29, 2013, 1:46 AM
Posted Jul 29, 2013, 1:32 AM
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);