I got an exception when executing the SQL statement in my code below.
The error is "Invalid object name
'db_dynamic_tra ding.dbo.TrdRpt _broker_list'".
I know for a fact that 'db_dynamic_tra ding.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 sConnectionStri ng = "Integrated
Security=SSPI;I nitial Catalog=db_dyna mic_trading;Dat a
Source=PANSQLDE V";
SqlConnection objConn = new
SqlConnection(s ConnectionStrin g);
objConn.Open();
string sSQL = "SELECT DISTINCT symbol_requeste d " +
"FROM
db_dynamic_trad ing.dbo.TrdRpt_ broker_list " +
"WHERE symbol_requeste d LIKE '%SCC%'";
SqlCommand objCmd = new SqlCommand(sSQL , objConn);
try
{
objCmd.ExecuteN onQuery();
}
catch (System.Excepti on e)
{
Console.WriteLi ne(e.Message);
}
Console.WriteLi ne("Records selected");
}
The error is "Invalid object name
'db_dynamic_tra ding.dbo.TrdRpt _broker_list'".
I know for a fact that 'db_dynamic_tra ding.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 sConnectionStri ng = "Integrated
Security=SSPI;I nitial Catalog=db_dyna mic_trading;Dat a
Source=PANSQLDE V";
SqlConnection objConn = new
SqlConnection(s ConnectionStrin g);
objConn.Open();
string sSQL = "SELECT DISTINCT symbol_requeste d " +
"FROM
db_dynamic_trad ing.dbo.TrdRpt_ broker_list " +
"WHERE symbol_requeste d LIKE '%SCC%'";
SqlCommand objCmd = new SqlCommand(sSQL , objConn);
try
{
objCmd.ExecuteN onQuery();
}
catch (System.Excepti on e)
{
Console.WriteLi ne(e.Message);
}
Console.WriteLi ne("Records selected");
}
Comment