Alright so using C# I am creating a DLL that I am using in SSMS and attaching it as an assembly to perform a few tasks, I can create/use the DLL fine but I am having trouble access the DB from the DLL to pull data in. If i was creating a form in C# to access the data i would do something like this
public class Gaps
{
public static void Find_Gaps1()
{
SqlConnection connection = new SqlConnection("Server = DIS; Database = dyn35; Integrated Security = true");
DataTable FinishDT = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter();
String SQLstatement = "SELECT [new_cust] FROM [Dyn35].[dbo].[Account] WHERE [new_cust] IS NOT NULL AND ISNUMERIC([new_cust]) = 1 ORDER BY [new_cust]";
connection.Open();
SqlCommand command = new SqlCommand(SQLstatement, connection);
command.CommandTimeout = 0;
adapter.SelectCommand = command;
adapter.Fill(FinishDT);
connection.Close();
}
}
Then i could easily manipulate the data that is in the Data Table. I cannot do this as a DLL because it throws an error stating i can't. Would anyone know how to send data from a query to a DLL using t-sql? Or point me in the right direction? The stored procedure I am creating is inside the same DB that I'm trying to access.
Yeah I believe it was a credential issue jdweng, once I set the sql connection context connection = true it was able to flow great!
SqlConnection connection = new SqlConnection("context connection = true");