Results 1 to 4 of 4

Thread: ADO connection in VB.NET

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61

    ADO connection in VB.NET

    Hi,

    I have referenced ADO2.7 .

    When i try to write import namespaces ,I could not find ADO.

    ie
    Import System.Data
    Imports System.Data.ADO(this ADO i could not find)

    I cannot declare object variable for ADODB.connection.

    if i try to write
    Dim conn as adodb.connection

    I am getting error is
    statement is not valid in a namespace


    How can i install and use MDAC2.o in my COM(Add reference)

    Please help me out.

    Thanks.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Don't use COM for data access anymore, not if you are doing .Net apps anyway.

    Here is a link to get you started:
    http://samples.gotdotnet.com/quickst...odtreader.aspx

  3. #3
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    I agree with hellswraith, but if you really want to use ADO2.7, the only thing you have to do is to add a reference to it in your application and you should be able to reference the namespace. I had a ADODB namespace anyway.

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61

    Thanks .it works well but i have new problem

    Hi,

    Thanks .It works well now but facing new problem.

    When i try to run the program it could not find the database application path and gives an error

    the error is:

    'System.runtime.interopservices.comException'occured in MArana form.exe

    additional inforamtion for error is:
    pl check the path name and spelled correctly.

    the code:


    Imports System.IO
    Imports System.Reflection

    Imports System.Windows.Forms.Application
    Imports System.Runtime.InteropServices.COMException



    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim mAppPath As String
    mAppPath = System.Reflection.Assembly.GetExecutingAssembly.Location

    Dim Conn As ADODB.Connection
    Dim objword As Word.Application

    Conn = New ADODB.Connection()


    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mAppPath & "\testdb.mdb;Mode=Share Deny None"
    Conn.Open()


    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width