WinBatch® Technical Support Forum

Archived Boards => COM Automation and dotNet => Topic started by: stanl on January 13, 2014, 02:56:24 AM

Title: Where is System.Data.SqlClient?
Post by: stanl on January 13, 2014, 02:56:24 AM
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?
Title: Re: Where is System.Data.SqlClient?
Post by: stanl on January 13, 2014, 06:56:36 AM
Oh, and before I get beat up about this, below is another user's problem with the namespace.

http://social.technet.microsoft.com/Forums/sqlserver/en-US/19b2465d-e090-4667-bb20-d4baceae54b5/how-to-get-systemdatasqlclient-back-in-referenceassembly-registry?forum=sqldataaccess (http://social.technet.microsoft.com/Forums/sqlserver/en-US/19b2465d-e090-4667-bb20-d4baceae54b5/how-to-get-systemdatasqlclient-back-in-referenceassembly-registry?forum=sqldataaccess)

Title: Re: Where is System.Data.SqlClient?
Post by: 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")
Title: Re: Where is System.Data.SqlClient?
Post by: stanl on January 13, 2014, 11:25:48 AM
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
Title: Re: Where is System.Data.SqlClient?
Post by: td on January 13, 2014, 01:11:22 PM
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;")

Title: Re: Where is System.Data.SqlClient?
Post by: stanl on January 13, 2014, 01:27:48 PM
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.