| | |
connecting to access via vb.net-HELP!!!
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
hey ppz! im havin problems wiv my code on vb.net! it dopesnt recognise the "ADODB connection()"-it says its not defined?? i have added the data adapter and connection, so why doesnt it work???
[PHP]Imports System.IO
Public Class frmClients
Inherits System.Windows.Forms.Form
Dim CN As New ADODB.Connection()
Dim RS As New ADODB.Recordset()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub[/PHP]
[PHP]Imports System.IO
Public Class frmClients
Inherits System.Windows.Forms.Form
Dim CN As New ADODB.Connection()
Dim RS As New ADODB.Recordset()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub[/PHP]
•
•
Join Date: Mar 2005
Posts: 65
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by shelly121
hey ppz! im havin problems wiv my code on vb.net! it dopesnt recognise the "ADODB connection()"-it says its not defined?? i have added the data adapter and connection, so why doesnt it work???
[PHP]Imports System.IO
Public Class frmClients
Inherits System.Windows.Forms.Form
Dim CN As New ADODB.Connection()
Dim RS As New ADODB.Recordset()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub[/PHP]
#Region " Windows Form Designer generated code "
Make all declarations after this code block. Also, you will need to add your imports statements at the very top:
Imports System()
Imports System.Data()
Imports System.Data.Oledb()
•
•
Join Date: Feb 2005
Posts: 18
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by shelly121
hey ppz! im havin problems wiv my code on vb.net! it dopesnt recognise the "ADODB connection()"-it says its not defined?? i have added the data adapter and connection, so why doesnt it work???
[PHP]Imports System.IO
Public Class frmClients
Inherits System.Windows.Forms.Form
Dim CN As New ADODB.Connection()
Dim RS As New ADODB.Recordset()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub[/PHP]
Well..What i can say is..
i'm not really good in Visual basic.net.but i'm doing on a project required to link database to my project. I'm using adodb connection.
Firstly,please check if you've added ADODB to your Reference ?
(if you've not or you're unsure.. double click on "Reference" on the Solution Explorer- check if you've "adodb"..if not right click on "Reference" .."Add Reference".Search for adodb and click select.)
If you've done the first part.. check this...
Imports System.Data.OleDb
Public Class frmClients
if you still have the problem pls let me know..i will try to help you..
•
•
Join Date: Feb 2005
Posts: 18
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by shelly121
hey ppz! im havin problems wiv my code on vb.net! it dopesnt recognise the "ADODB connection()"-it says its not defined?? i have added the data adapter and connection, so why doesnt it work???
[PHP]Imports System.IO
Public Class frmClients
Inherits System.Windows.Forms.Form
Dim CN As New ADODB.Connection()
Dim RS As New ADODB.Recordset()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub[/PHP]
•
•
Join Date: Aug 2004
Posts: 19
Reputation:
Solved Threads: 0
Hi,
Try this code. For MS access, change accordingly.
Purpose :To retrieve data from the database using Data Reader and Data Commands. When this code is executed, the data in a database is displayed in two textbox controls.
Preparation:
Design a form using .NET environment and place two textbox controls on a form.
Design and create a table using SQL Server 2000.
Name the Database as FinAccounting.
Name the Table as AccountsTable.
Name the form as Form1
Name the controls on the form as Textbox1 and Textbox2.
Tasks:
1. Establish the connection with the Database using Connection object.
2. Execute the command.
3. The data will be read by the Datareader object and the contents of the first record is displayed in the textboxes.
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim str_sql_user_select As String = “SELECT * FROM AccountsTable�
Dim str_connection As String = “Data Source=VSDOTNET;Integrated Security=SSPI;Initial Catalog=FinAccounting�
Dim mycon As SqlConnection
Dim comUserSelect As SqlCommand
Dim myreader As SqlDataReader
Private Sub Form1_Load(ByVal sender As Object, ByVal e As system.EventArgs) Handles
MyBase.Load
mycon = New SqlConnection(str_connection)
‘Instantiate the commands
comUserSelect = New SqlCommand(str_sql_user_select, mycon)
TextBox1.Text = “ “
TextBox2.Text = “ “
mycon.Open()
myreader = comUserSelect.ExecuteReader
If (myreader.Read = True) Then
TextBox1.Text = myreader(0)
TextBox2.Text = myreader(1)
Else
MsgBox(“You have reached eof�)
End If
End Sub
End Class
Regards
Bhar
Books fro programmers
http://www.vkinfotek.com
Try this code. For MS access, change accordingly.
Purpose :To retrieve data from the database using Data Reader and Data Commands. When this code is executed, the data in a database is displayed in two textbox controls.
Preparation:
Design a form using .NET environment and place two textbox controls on a form.
Design and create a table using SQL Server 2000.
Name the Database as FinAccounting.
Name the Table as AccountsTable.
Name the form as Form1
Name the controls on the form as Textbox1 and Textbox2.
Tasks:
1. Establish the connection with the Database using Connection object.
2. Execute the command.
3. The data will be read by the Datareader object and the contents of the first record is displayed in the textboxes.
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim str_sql_user_select As String = “SELECT * FROM AccountsTable�
Dim str_connection As String = “Data Source=VSDOTNET;Integrated Security=SSPI;Initial Catalog=FinAccounting�
Dim mycon As SqlConnection
Dim comUserSelect As SqlCommand
Dim myreader As SqlDataReader
Private Sub Form1_Load(ByVal sender As Object, ByVal e As system.EventArgs) Handles
MyBase.Load
mycon = New SqlConnection(str_connection)
‘Instantiate the commands
comUserSelect = New SqlCommand(str_sql_user_select, mycon)
TextBox1.Text = “ “
TextBox2.Text = “ “
mycon.Open()
myreader = comUserSelect.ExecuteReader
If (myreader.Read = True) Then
TextBox1.Text = myreader(0)
TextBox2.Text = myreader(1)
Else
MsgBox(“You have reached eof�)
End If
End Sub
End Class
Regards
Bhar
Books fro programmers
http://www.vkinfotek.com
•
•
Join Date: May 2005
Posts: 12
Reputation:
Solved Threads: 0
Here's what I did
myPath = "c:\Table.mdb"
myQuery = "select * from table"
Public Function Return_Access(ByVal myQuery As String, ByVal myPath As String) As DataSet
Dim myConnStr As String = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" + myPath
Dim myConn As New OleDb.OleDbConnection(myConnStr)
Dim myAdapt As New OleDb.OleDbDataAdapter(myQuery, myConn)
Try
myConn.Open()
Dim myReader As New DataSet
myAdapt.Fill(myReader)
Return myReader
myConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
myPath = "c:\Table.mdb"
myQuery = "select * from table"
Public Function Return_Access(ByVal myQuery As String, ByVal myPath As String) As DataSet
Dim myConnStr As String = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" + myPath
Dim myConn As New OleDb.OleDbConnection(myConnStr)
Dim myAdapt As New OleDb.OleDbDataAdapter(myQuery, myConn)
Try
myConn.Open()
Dim myReader As New DataSet
myAdapt.Fill(myReader)
Return myReader
myConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
![]() |
Similar Threads
- how to update an access DB with vb.net? (ASP.NET)
- Retreive Data Between Two Dates From Ms-access Using Vb.net (VB.NET)
- Connecting to MS Access with PHP (PHP)
- connecting to a dataabase in vb.net (VB.NET)
- Need help with ms access and vb.net (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Need help with calculation
- Next Thread: Creating a conduit in VB .NET
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google gridview hardcopy html images input insert intel internet mobile monitor net networking objects open output panel passingparameters pdf picturebox port position print printing problem save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





