I want to run this query in C#
SELECT *
FROM [FirstDataBase].[dbo].[table1]
INNER JOIN [SecondDataBase].[dbo].[table2]
and my code is :
SqlConnection cn = new SqlConnection(myConnectionString);
SqlCommand cmd = new SqlCommand(@"SELECT * FROM [FirstDataBase].[dbo].[table1]
INNER JOIN [SecondDataBase].[dbo].[table2]");
cmd.Connection = cn; // here is my question !!!
cn.Open();
int x = (int)cmd.ExecuteScalar();
but my query needs two connection string ... one for [FirstDataBase] and second
for [SecondDataBase]...
How can I do this ?
How can I insert two SqlConnection
or ConnectionString
to one SqlCommand
? or
How can I do it in other ways ?