Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
2.22/5 (2 votes)
See more:
Imports System.Data.OleDb
Public Class Form1
Dim dtHospitalBilling As DataTable()
Dim dbConnection As OleDbConnection
Dim dbCommand As OleDbCommand
Dim dbDataAdapter As OleDbDataAdapter
Dim ConnectString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nuri\Documents\Visual Studio 2010\Projects\HospitalBilling\HospitalBilling\Hospital.accdb"
Dim dtHospital As DataTable
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'HospitalDataSet1.Hospital' table. You can move, or remove it, as needed.
dbConnection.Open()
Me.HospitalTableAdapter.Fill(Me.HospitalDataSet1.Hospital)

End Sub

Private Sub btnAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAll.Click
Dim DbConnection As OleDbConnection
Dim dsFirstName As New DataSet()

DbConnection = New OleDbConnection(ConnectString)
dbDataAdapter = New OleDbDataAdapter()
dbCommand = New OleDbCommand()
dbCommand.CommandText = ""
dbCommand.CommandType = CommandType.StoredProcedure
dbDataAdapter.SelectCommand = dbCommand
dbDataAdapter.SelectCommand.Connection = dbConnection
DbConnection.Open()
dbCommand.ExecuteNonQuery()
dbDataAdapter.Fill(dsFirstName, "Hospital")
DataGridView1.DataSource = dsFirstName
DataGridView1.DataMember = "Hospital"
DbConnection.Close()



End Sub
Posted

1 solution

You can't get information from Access without any SQL - because it's the SQL that tells it what information you want to retrieve!

As a minimum, you need to provide the name of your stored procedure as the CommandText parameter. This:
VB
dbCommand.CommandText = ""
Will either cause an error, or no data to be retrieved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900