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

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 17
Reputation: shelly121 is an unknown quantity at this point 
Solved Threads: 0
shelly121 shelly121 is offline Offline
Newbie Poster

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

 
0
  #1
Feb 21st, 2005
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]
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 65
Reputation: cpopham is an unknown quantity at this point 
Solved Threads: 0
cpopham cpopham is offline Offline
Junior Poster in Training

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

 
0
  #2
Mar 14th, 2005
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()
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 18
Reputation: N[e]tt[e] is an unknown quantity at this point 
Solved Threads: 0
N[e]tt[e] N[e]tt[e] is offline Offline
Newbie Poster

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

 
0
  #3
Mar 25th, 2005
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..
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 18
Reputation: N[e]tt[e] is an unknown quantity at this point 
Solved Threads: 0
N[e]tt[e] N[e]tt[e] is offline Offline
Newbie Poster

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

 
0
  #4
Apr 4th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1
Reputation: NkomoFF is an unknown quantity at this point 
Solved Threads: 0
NkomoFF NkomoFF is offline Offline
Newbie Poster

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

 
0
  #5
May 3rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 19
Reputation: Bharati Krishna is an unknown quantity at this point 
Solved Threads: 0
Bharati Krishna Bharati Krishna is offline Offline
Newbie Poster

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

 
0
  #6
May 17th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 12
Reputation: Robert Walker is an unknown quantity at this point 
Solved Threads: 0
Robert Walker Robert Walker is offline Offline
Newbie Poster

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

 
0
  #7
May 17th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC