question

BrandonStewart-4522 avatar image
0 Votes"
BrandonStewart-4522 asked ·

Visual Basic database support under .NET Core 5

I have a couple of Visual Basic apps, each of which connects to a local Microsoft Access database. I have upgraded my apps from using the .NET Framework to now use .NET Core 5. For some reason, I can no longer add a new data source via the wizard, nor by manually coding. I can still do it when creating VB WinForms app under the Framework, but not under .NET 5. This should be incredibly simply to do. Does VB under .NET 5 no longer support connecting to a database? I cannot find anything on a Google search which mentions anything about connecting to a local database under .NET 5, and the methods of doing it under .NET Framework don't seem to work.

dotnet-adonet
· 3
10 |1000 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.

Whatever database you are trying to use, I don't see why you cannot just use straight-up ADO.NET, database command objects and T-SQL manually to access a given database provider's database.

I think it comes down to do you know how to use ADO.NET manually without Mr. Wizard?

1 Vote 1 ·

No, I don't know how to use it without "Mr. Wizard". But that's not the point. The wizard should work - or it should be remove it all together.
Microsoft needs to either stop breaking crap, or stop expecting people to want to use their broken products.

My database apps are very, very simple. Or, at least they should be, which is the reason for using Visual Basic and it's wizards to begin with. If I lose that simplicity, then I need to drop Microsoft products and go with a different design environment which is just a quick and easy for my simple needs.

0 Votes 0 ·
DuaneArnold-0443 avatar image DuaneArnold-0443 BrandonStewart-4522 ·

No, I don't know how to use it without "Mr. Wizard". But that's not the point. The wizard should work - or it should be remove it all together.
Microsoft needs to either stop breaking crap, or stop expecting people to want to use their broken products.

And you expect to jump from the .NET Framework to .NET Core, like it's a stroll in the park? No, that's not happening.

IMHO you need to stop using Mr. Wizard and learn how to do things without Mr. Wizard, if you expect to be using .NET Core.

And the Mr. Wizard as you say works for .Net Framework solutions, then maybe its best to stay on the .Net Framework version 4.8 where .NET Framework will stop forever.

And if what you need to do is move to another platform and programming language, then you should do it.

But I suggest that you go to the VB.NET forum in QandA and talk to the VB community experts there about .NET Core 5.0,Visual Stuido 2019 and Mr. Wizard being viable.

0 Votes 0 ·

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered ·

Hi BrandonStewart-4522,
Follow the steps below, you will find that "this window is not supported for the selected project." in Winforms(VB) .NET5.
1.Open the Data Sources window, on the View menu, select Other Windows > Data Sources.
It means that the wizard is not supported yet. So you need to connect to the database manually.
I made a test and can access the local Microsoft Access database successfully.
First add data connection in Server Explorer which on View menu.
78559-317.png
Then use the following code example to load records from Access Database to Datagridview.

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\danielzh\Desktop\test.accdb")
     Try
         con.Open()
    
         If con.State = ConnectionState.Open Then
             MsgBox("Connected")
         Else
             MsgBox("Not Connected!")
    
         End If
     Catch ex As Exception
         MsgBox(ex.Message)
     Finally
         con.Close()
     End Try
     Try
         Dim sql As String
         Dim cmd As New OleDb.OleDbCommand
         Dim dt As New DataTable
         Dim da As New OleDb.OleDbDataAdapter
         con.Open()
         sql = "Select * from Table1"
         cmd.Connection = con
         cmd.CommandText = sql
         da.SelectCommand = cmd
    
         da.Fill(dt)
    
         DataGridView1.DataSource = dt
     Catch ex As Exception
         MsgBox(ex.Message)
     Finally
         con.Close()
     End Try
 End Sub

Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentationto enable e-mail notifications if you want to receive the related email notification for this thread.



317.png (6.6 KiB)
·
10 |1000 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.