954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

connecting to access via vb.net-HELP!!!

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]

shelly121
Newbie Poster
17 posts since Feb 2005
Reputation Points: 10
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]

You should not make your declarations before the:
#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()

cpopham
Junior Poster in Training
65 posts since Mar 2005
Reputation Points: 10
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]


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..

N[e]tt[e]
Newbie Poster
18 posts since Feb 2005
Reputation Points: 10
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]


em how's it?

N[e]tt[e]
Newbie Poster
18 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

Use MS Jet4 and then bound the fields using text and source data on the text boxes properties, this is fir each text box used

NkomoFF
Newbie Poster
1 post since May 2004
Reputation Points: 10
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

Bharati Krishna
Newbie Poster
19 posts since Aug 2004
Reputation Points: 10
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

Robert Walker
Newbie Poster
12 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You