Results 1 to 3 of 3

Thread: MSDE Connection

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    53

    MSDE Connection

    Dim tbl As New ADOX.Table
    Dim cn As New ADODB.Connection
    Dim cl As New ADOX.Column
    Dim cat As New ADOX.Catalog

    'Open Connection to Data Source
    With cn
    .ConnectionString = "PROVIDER=sqloledb;DATA SOURCE=ServerName;USER ID=userID;PASSWORD=Password;INITIAL CATALOG=pubs"
    .Open

    End With

    'Associate the Catalog object to the Connection.
    With cat
    .ActiveConnection = cn
    End With

    'Create a table definition.
    With tbl
    .Name = "MyADOXtbl"
    End With

    'Create a Column definition.
    With cl
    .Name = "Col1"
    .DefinedSize = 10
    .Type = adChar
    .Attributes = adColFixed + adColNullable
    End With

    'Add the Column definition to the table table definition.
    tbl.Columns.Append cl

    'Create the table on the Data Source
    cat.Tables.Append tbl



    When Ado is opened it gives the message "SQL SErver dosen't exit or ascess denied"

    If I try to connect the SQL Server (MSDE ) using the below code it connects , Where am I wrong in the above code , Please help to connect the local MSDE using the ADODB or ADOX connection

    Dim mOSQLServer As SQLDMO.SQLServer
    Set mOSQLServer = New SQLDMO.SQLServer

    With mOSQLServer
    .LoginSecure = True
    .AutoReConnect = False
    .Connect SERVERNANE,USERID, PASSWORD
    End With

  2. #2
    Junior Member
    Join Date
    Oct 2003
    Location
    Earth
    Posts
    23
    I guess thats a VB6 codes, right ? r u wrong place ?

    For ASP.net u must using ADO.net not ADO

    For connecting to SQL server with ADO.net, use SqlConnection.
    And for connecting to Access database with ADO.net, use OledbConnection.

    This for connecting to SQL server with ADO.net and view the data with datagrid control :

    Imports System.Data
    Imports System.Data.SqlClient

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Dim myConn As SqlConnection
    myConn = New SqlConnection("server=RIO\VSdotNET;" & "Trusted_Connection=true; database=pubs")
    myConn.Open()

    Dim strselect As String = "select TITLE,TYPE,PRICE from titles"
    Dim mysql As SqlCommand = New SqlCommand(strselect, myConn)
    Dim myreader As SqlDataReader
    myreader = mysql.ExecuteReader()

    DataGrid1.DataSource = myreader
    DataGrid1.DataBind()

    myreader.Close()
    myConn.Close()
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    53
    Thanks Rio

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