I'm facing a problem for connecting to my database .I wanna connect to one of my sqlserver's DB and I use SqlConnection
but when I open my database connection there's an error with this title "LoaderLock was detected" and this message :
"Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang."
and here's the code :
{
SqlConnection sc = new SqlConnection("Data Source=.;Initial Catalog=DB1;Integrated Security=True");
SqlCommand scom = new SqlCommand(@"insert into t1 values(2,'Daniel')", sc);
sc.Open();
scom.ExecuteNonQuery();
sc.Close();
}
Please help me through this problem,what am I missing here ? and what should I do?