Can i use @ symbol for bind variables instead of colon for O
Posted: Wed 15 Jul 2009 07:18
Dear helpers,
Previously we are using sql server 2005 database(and visual studio as client) so the code to
retrieve data as follows
StringBuilder selectQuery = new StringBuilder();
selectQuery.Append("SELECT INTER_DIVISION_TRX_ON_SHIP ");
selectQuery.Append("FROM COR_DIV ");
selectQuery.Append("WHERE DIVISION_ID = @divisionId");
SqlConnection connection = null;
SqlCommand command = null;
SqlDataReader reader = null;
try
{
// get the connection and create the statement
connection = GetOpenConnection();
command = connection.CreateCommand();
command.CommandText = selectQuery.ToString();
DBUtil.SetIntParam(command, "@divisionId", divisionId);
interDivisionTrxOnShip = command.ExecuteScalar().ToString();
}
catch (Exception ex)
{
}
in DBUtil.SetIntParam method the code as follows
public static void SetIntParam(IDbCommand command, string paramName,
int paramValue)
{
IDbDataParameter param = command.CreateParameter();
param.ParameterName = paramName;
if (paramValue != int.MinValue)
{
param.Value = paramValue;
}
else
{
param.Value = DBNull.Value;
}
command.Parameters.Add(param);
}
Now we migrate our database to oracle 11g,so we need to use ODP.Net data provider,
now my problem is i need to follow the same syntax as described above without changing
@ symbol for bind variables can you please help me to satisfy my needs.
Previously we are using sql server 2005 database(and visual studio as client) so the code to
retrieve data as follows
StringBuilder selectQuery = new StringBuilder();
selectQuery.Append("SELECT INTER_DIVISION_TRX_ON_SHIP ");
selectQuery.Append("FROM COR_DIV ");
selectQuery.Append("WHERE DIVISION_ID = @divisionId");
SqlConnection connection = null;
SqlCommand command = null;
SqlDataReader reader = null;
try
{
// get the connection and create the statement
connection = GetOpenConnection();
command = connection.CreateCommand();
command.CommandText = selectQuery.ToString();
DBUtil.SetIntParam(command, "@divisionId", divisionId);
interDivisionTrxOnShip = command.ExecuteScalar().ToString();
}
catch (Exception ex)
{
}
in DBUtil.SetIntParam method the code as follows
public static void SetIntParam(IDbCommand command, string paramName,
int paramValue)
{
IDbDataParameter param = command.CreateParameter();
param.ParameterName = paramName;
if (paramValue != int.MinValue)
{
param.Value = paramValue;
}
else
{
param.Value = DBNull.Value;
}
command.Parameters.Add(param);
}
Now we migrate our database to oracle 11g,so we need to use ODP.Net data provider,
now my problem is i need to follow the same syntax as described above without changing
@ symbol for bind variables can you please help me to satisfy my needs.