question

AnthonyWhite-8081 avatar image
0 Votes"
AnthonyWhite-8081 asked Bruce-SqlWork commented

SqlConnection and SqlDataAdapter not found in vb.net 6.0

I am trying to write a simple application to access an SQL database, but cannot reference SqlConnection or SqlDataServer. I've added
System.Data
System.Data.SqlClient
System.Data.OleDb

to the project.

Once again, this is using vb.net 6.0

dotnet-visual-basicdotnet-adonetdotnet-sqlclient
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered Bruce-SqlWork edited

net 6 no longer includes System.Data.SqlClient as Microsoft.Data.SqlClient is the recommend replacement. you must use a nuget package to induce the old or new package.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm still not sure which package to install - Microsoft.Data.SqlClient doesn't seem to be an available package.

The relevant packages are:
Microsoft.NETCore.App
Microsoft.NETCor.Targets

While I am not new to VB, I haven't used it in many years.

0 Votes 0 ·
Bruce-SqlWork avatar image Bruce-SqlWork AnthonyWhite-8081 ·

if its a new project you should use Microsoft.Data.SqlClient:

https://www.nuget.org/packages/Microsoft.Data.SqlClient/5.0.1

if you want to use the old library:

https://www.nuget.org/packages/System.Data.SqlClient




0 Votes 0 ·
AnthonyWhite-8081 avatar image
0 Votes"
AnthonyWhite-8081 answered Bruce-SqlWork commented

Thanks for the help.

I think I am going to just switch to C# for my .NET endeavors.

I am an old C++ hack. The C# examples work (I've been having a LOT of problems getting the VB examples to work with .NET 6 for what should be simple stuff), and C# just make more sense to me in terms of styling.

This may be going off topic for this question, but anyone feel free to tell me that I am wrong, and stick with VB...

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

the .net core runtime, is now tightly coupled to C# and they are released in sync. vb.net is on its own release and feature cycle. thus some runtime features it may never support, or be behind, BB.net is no a mature product, and the focus is to let it run on the current runtime.

so, if you want the latest .net features, you should use C#, if you don't like changes and want more stable environment, then VB is an option.

0 Votes 0 ·