Author Topic: Where is System.Data.SqlClient?  (Read 6422 times)

stanl

  • Pundit
  • *****
  • Posts: 777
Where is System.Data.SqlClient?
« 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?

stanl

  • Pundit
  • *****
  • Posts: 777
Re: Where is System.Data.SqlClient?
« Reply #1 on: January 13, 2014, 06:56:36 am »

td

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: Where is System.Data.SqlClient?
« Reply #2 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
ObjectClrOption("use", "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objSqlConn = ObjectClrNew("System.Data.SqlClient.SqlConnection")
 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


stanl

  • Pundit
  • *****
  • Posts: 777
Re: Where is System.Data.SqlClient?
« Reply #3 on: January 13, 2014, 11:25:48 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
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

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: Where is System.Data.SqlClient?
« Reply #4 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
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;")
 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


stanl

  • Pundit
  • *****
  • Posts: 777
Re: Where is System.Data.SqlClient?
« Reply #5 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.