Where is System.Data.SqlClient?

Started by stanl, January 13, 2014, 02:56:24 AM

Previous topic - Next topic

stanl

I have been using the System.Data.Oledb classes to work with SQL Server, but it seems the System.Data.SqlClient classes are more robust. I have the .net frameworks and service patches through 4.5, the ADO.Net Entity Framework 41, loads of specific SQLServer class in the GAC, but for some reason I can't do anything with the Sql.Client assembly in a WB script.

Supposedly SqlClient in part of System.Data namespace (ADO.Net??), or at least that is the answer other users get when they post issues about not being able to use it.  Any ideas about how I might integrate it into a WB script?


td

What specific problem are you having?  The name space "System.Data.SqlClient" is in the "System.Data" assembly and you should be able to instantiate class instances that are part of that name space.  The following fragment confirms this fact on my system
Code (winbatch) Select

ObjectClrOption("use", "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objSqlConn = ObjectClrNew("System.Data.SqlClient.SqlConnection")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on January 13, 2014, 06:58:09 AM
What specific problem are you having?  The name space "System.Data.SqlClient" is in the "System.Data" assembly and you should be able to instantiate class instances that are part of that name space.  The following fragment confirms this fact on my system
Code (winbatch) Select

ObjectClrOption("use", "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objSqlConn = ObjectClrNew("System.Data.SqlClient.SqlConnection")


well if I

cn = ObjectClrNew("System.Data.SqlClient.SqlConnection",cConn)
;cn = ObjectClrNew("System.Data.OleDb.OleDbConnection",cConn)
cn.Open()

I get an mscorlib exception error which I don't get with OleDb

td

Did you check out the More Error Info button?  It has been my experience that the CLR will tell you something about what is wrong with your connection string when it finds something it doesn't like.  This is fragment from an old script hanging about on a computer with SQL Express and a test db.
Code (winbatch) Select

ObjectClrOption("use", "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objSqlConn = ObjectClrNew("System.Data.SqlClient.SqlConnection", "Server=.\SQLEXPRESS;Database=TestBin;Trusted_Connection=yes;")

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Right: I was using a Provider=SQLOLEDB.1 connection {dumb}. But now having other issues as after I create a linked server (with either ADO or the CLR) when I try to open or test the link, I get the attached error. Not a WB issue. I have reinstalled 2008 R2, and swear linked servers worked before.

EDIT:  Easy fix, just changes the server to local service.