C
Curious
I got an exception when executing the SQL statement in my code below.
The error is "Invalid object name
'db_dynamic_trading.dbo.TrdRpt_broker_list'".
I know for a fact that 'db_dynamic_trading.dbo.TrdRpt_broker_list' is
valid, because I can run the same SQL statement in Management Studio
and it works.
Any advice on this? Is there anything wrong with my connection string
(although there is no complaint about the connection string in my
debugger)?
static void Main(string[] args)
{
string sConnectionString = "Integrated
Security=SSPI;Initial Catalog=db_dynamic_trading;Data
Source=PANSQLDEV";
SqlConnection objConn = new
SqlConnection(sConnectionString);
objConn.Open();
string sSQL = "SELECT DISTINCT symbol_requested " +
"FROM
db_dynamic_trading.dbo.TrdRpt_broker_list " +
"WHERE symbol_requested LIKE '%SCC%'";
SqlCommand objCmd = new SqlCommand(sSQL, objConn);
try
{
objCmd.ExecuteNonQuery();
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Records selected");
}
The error is "Invalid object name
'db_dynamic_trading.dbo.TrdRpt_broker_list'".
I know for a fact that 'db_dynamic_trading.dbo.TrdRpt_broker_list' is
valid, because I can run the same SQL statement in Management Studio
and it works.
Any advice on this? Is there anything wrong with my connection string
(although there is no complaint about the connection string in my
debugger)?
static void Main(string[] args)
{
string sConnectionString = "Integrated
Security=SSPI;Initial Catalog=db_dynamic_trading;Data
Source=PANSQLDEV";
SqlConnection objConn = new
SqlConnection(sConnectionString);
objConn.Open();
string sSQL = "SELECT DISTINCT symbol_requested " +
"FROM
db_dynamic_trading.dbo.TrdRpt_broker_list " +
"WHERE symbol_requested LIKE '%SCC%'";
SqlCommand objCmd = new SqlCommand(sSQL, objConn);
try
{
objCmd.ExecuteNonQuery();
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Records selected");
}