|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Data and System.Data.SqlClient - Which one should I use ?SQL2000 I now want to convert this project to VS2005 I've currently referenced: D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll (Version = 2.0.0.0) AND: D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll (Version = 3.0.3600.0) The question is: which one should I be using, and why does System.Data ALSO contain a definition for SQLConnection (Currently I get an error in my project): An assembly with the same identity 'System.Data.SqlClient, Version=3.0.3600.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, Retargetable=Yes' has already been imported. Try removing one of the duplicate references. --- I know how to get rid of it (only reference one of the DLLs) but want to know WHY it is happening. Simply put, System.Data is a generalized namespace for the most common
classes like DataSets, DataReaders, etc. System.Data.SqlClient is the namespace you'd use when working with SQL Server, specifically. There are other namespaces like System.Data.OdbcClient and OledbClient which are for other databases. HTH -Altaf -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "Steven Wilmot" <steven-n***@wilmot.me.uk> wrote in message news:OyfVj7J6FHA.2552@TK2MSFTNGP10.phx.gbl... > I've recently started to convert an old VS2003 project that was using some > SQL2000 > > I now want to convert this project to VS2005 > > I've currently referenced: > D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll > (Version = 2.0.0.0) > AND: > D:\Program Files\Microsoft Visual Studio > 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll (Version = > 3.0.3600.0) > > The question is: which one should I be using, and why does System.Data > ALSO contain a definition for SQLConnection > > (Currently I get an error in my project): > > An assembly with the same identity 'System.Data.SqlClient, > Version=3.0.3600.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, > Retargetable=Yes' has already been imported. Try removing one of the > duplicate references. > > --- > > I know how to get rid of it (only reference one of the DLLs) but want to > know WHY it is happening. > > > "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message Unfortunately, this completely misses the point of my question.news:ulU2imS6FHA.2576@TK2MSFTNGP09.phx.gbl... > Simply put, System.Data is a generalized namespace for the most common > classes like DataSets, DataReaders, etc. System.Data.SqlClient is the > namespace you'd use when working with SQL Server, specifically. There are > other namespaces like System.Data.OdbcClient and OledbClient which are for > other databases. > > HTH > -Altaf > I realise what the different namespaces are fo - I am asking about the two assemblies D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll This contains the namespace System.Data This also contains the namespace System.Data.SqlClient D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll This also contains the namespace System.Data.SqlClient ... But, this depends on the definition of the type 'System.Data.IDbConnection' , which is defined in an assembly that is not referenced.: ( 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac) However, if I then add the System.Data.Dll assembly, I am presented with another error. An assembly with the same identity 'System.Data.SqlClient, Version=3.0.3600.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, Retargetable=Yes' has already been imported. Try removing one of the duplicate references. d:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll WindowsApplication2 ---- This makes the version of System.Data.SqlClient.DLL (v3.0.6000.0) incompatible with the v2.0.50727 of the .NET framework ....
Show quote
"Steven Wilmot" <Steven_W@newsgroups.nospam> wrote in message For example:news:uvOkxWU6FHA.2036@TK2MSFTNGP14.phx.gbl... > > "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message > news:ulU2imS6FHA.2576@TK2MSFTNGP09.phx.gbl... >> Simply put, System.Data is a generalized namespace for the most common >> classes like DataSets, DataReaders, etc. System.Data.SqlClient is the >> namespace you'd use when working with SQL Server, specifically. There >> are other namespaces like System.Data.OdbcClient and OledbClient which >> are for other databases. >> >> HTH >> -Altaf >> > > Unfortunately, this completely misses the point of my question. > > I realise what the different namespaces are fo - I am asking about the two > assemblies > > D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll > This contains the namespace System.Data > This also contains the namespace System.Data.SqlClient > > D:\Program Files\Microsoft Visual Studio > 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll > This also contains the namespace System.Data.SqlClient > ... But, this depends on the definition of the type > 'System.Data.IDbConnection' , which is defined in an assembly that is not > referenced.: > ( 'System.Data, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=969db8053d3322ac) > > However, if I then add the System.Data.Dll assembly, I am presented with > another error. > > An assembly with the same identity 'System.Data.SqlClient, > Version=3.0.3600.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, > Retargetable=Yes' has already been imported. Try removing one of the > duplicate references. d:\Program Files\Microsoft Visual Studio > 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll > WindowsApplication2 > > ---- > > This makes the version of System.Data.SqlClient.DLL (v3.0.6000.0) > incompatible with the v2.0.50727 of the .NET framework .... > Try referencing both assemblies, then create a simple C# project with the following two lines of code: System.Data.SqlClient.SqlConnection a = new System.Data.SqlClient.SqlConnection(); MessageBox.Show(a.State.ToString()); "Steven Wilmot" <Steven_W@newsgroups.nospam> wrote in message You should only referencenews:OQWdnfU6FHA.3876@TK2MSFTNGP09.phx.gbl... >> The question is: which one should I be using, and why does System.Data >> ALSO contain a definition for SQLConnection D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll (This is the one referenced by default in both C# and VB) It contains both System.Data and System.Data.SqlClient namespaces. I am not sure what the other one is used for (or why it has some similar classnames), but you definately don't want to be referencing it. Maybe it an assembly specifically written for use by the IDE? Confusing, isn't it? :^) Greg |
|||||||||||||||||||||||