943,864 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 35164
  • VB.NET RSS
Feb 21st, 2005
0

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

Expand Post »
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]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Mar 14th, 2005
0

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

Quote 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]
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()
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cpopham is offline Offline
65 posts
since Mar 2005
Mar 25th, 2005
0

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

Quote 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..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
N[e]tt[e] is offline Offline
18 posts
since Feb 2005
Apr 4th, 2005
0

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

Quote 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]
em how's it?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
N[e]tt[e] is offline Offline
18 posts
since Feb 2005
May 3rd, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
NkomoFF is offline Offline
1 posts
since May 2004
May 17th, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bharati Krishna is offline Offline
19 posts
since Aug 2004
May 17th, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Robert Walker is offline Offline
12 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Need help with calculation
Next Thread in VB.NET Forum Timeline: Creating a conduit in VB .NET





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC