vb.net SqlConnection open DB passing PATH

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • neodev

    #1

    vb.net SqlConnection open DB passing PATH

    Hi
    I have 2 mode for open db

    'Path DB
    Private Const pathDB As String = "C:\...\diaboli k.mdb"
    'for the ole db
    Private conn As New OleDbConnection
    'for th sqlconnection
    Private connRS As Data.SqlClient. SqlConnection

    If I want open Local DB using a path and not using DNS
    because I doen't know the mode.

    For OleDbConnection I write :
    conn.Connection String = _
    "Provider = Microsoft.Jet.O LEDB.4.0;Data Source =" & pathDB

    where is the method for open connection to local db
    using your path and not dns string or othen

    connRS.Connecti onString = _
    "Server=(local) ;Initial Catalog=diaboli k;" & _
    "Data Source=(" & pathDB & ")"

    but doen't work
    I want know if possible using sqlconnection passing
    path of DataBase ????!!!!!


    HELP ME PLEASE

    NEODEV
    Fabio Santini

  • Kerry Moorman

    #2
    RE: vb.net SqlConnection open DB passing PATH

    Fabio,

    Sqlconnection is for working with Microsoft SQL Server databases, not Access
    databases.

    Kerry Moorman


    "neodev" wrote:
    [color=blue]
    > Hi
    > I have 2 mode for open db
    >
    > 'Path DB
    > Private Const pathDB As String = "C:\...\diaboli k.mdb"
    > 'for the ole db
    > Private conn As New OleDbConnection
    > 'for th sqlconnection
    > Private connRS As Data.SqlClient. SqlConnection
    >
    > If I want open Local DB using a path and not using DNS
    > because I doen't know the mode.
    >
    > For OleDbConnection I write :
    > conn.Connection String = _
    > "Provider = Microsoft.Jet.O LEDB.4.0;Data Source =" & pathDB
    >
    > where is the method for open connection to local db
    > using your path and not dns string or othen
    >
    > connRS.Connecti onString = _
    > "Server=(local) ;Initial Catalog=diaboli k;" & _
    > "Data Source=(" & pathDB & ")"
    >
    > but doen't work
    > I want know if possible using sqlconnection passing
    > path of DataBase ????!!!!!
    >
    >
    > HELP ME PLEASE
    >
    > NEODEV
    > Fabio Santini
    >
    >[/color]

    Comment

    • neodev

      #3
      Re: vb.net SqlConnection open DB passing PATH

      OK thank Ops
      but Anothe question a want fill grid with data from access

      sql = "SELECT * FROM albi where RIFAnno= " & RIFAnno
      If conn.State = Data.Connection State.Closed Then conn.Open()
      cmd1 = conn.CreateComm and
      cmd1.CommandTex t = sql
      rd1 = cmd1.ExecuteRea der()

      gridAlbo.DataSo urce = rd1
      gridAlbo.databi nd()


      but vs 005 beta2 give me error in gridAlbo.databi nd()
      DATABIND NOT IS A METHOD

      ANY IDEA
      thanks
      fabio

      Comment

      Working...