Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    3

    Unanswered: VB .net webform connect with SQL server

    Working with VB.net, creating a web form, I can't connect to my MSSQL2K database; the message i get is 'it is only possible to connect to MS SQL Desktop Engine databases... with this version of Visual Studio'. The Test Connection button on the new connection wizard tells me 'connection succeeded', and I can connect to the database when creating a windows form. I am running the MSSQL evaluation copy and VB.net standard version (I am a student). Is there any way to make this work with web forms? Thanks for help.

  2. #2
    Join Date
    Sep 2003
    Posts
    66
    Hope will help:
    <%@ Import Namespace="System.Data" %>

    <%@ Import Namespace="System.Data.ADO" %>

    <%

    'connection string...

    Dim strConnString as String

    strConnString = "Provider=SQLOLEDB; Data Source=(local); " & _

    "Initial Catalog=pubs; User ID=sa"



    'create object ADOConnection

    Dim objConn as ADOConnection

    objConn = New ADOConnection



    'set ADOCOnnectionString to MS - SQL Serverconnection string

    objConn.ConnectionString = strConnString



    objConn.Open() 'open connection



    'SQL

    Dim strSQL as String = "SELECT * FROM authors"



    'create ADODatasetCommand ,Dataset

    Dim objDSCommand as ADODatasetCommand

    Dim objDataset as Dataset = New Dataset

    objDSCommand = New ADODatasetCommand(strSQL, objConn)



    'fill data set with info: "Author Information"

    objDSCommand.FillDataSet(objDataset, "Author Information")



    objConn.Close()

    objConn = Nothing





    Authors.DataSource = _

    objDataset.Tables("Author Information").DefaultView

    Authors.DataBind()



    %>



    <HTML>

    <BODY>

    <aspataGrid id="Authors" runat="server"/>

    </BODY>

    </HTML>

  3. #3
    Join Date
    Sep 2003
    Posts
    3
    Thanks for the suggestion. It will work for a Windows form, but not for the web form; I get the 'server does not exist or access denied'. trying to connect with connection wizard, i get 'unable to connect to database. it is only possible to connect to Sql Server Desktop Engine databases and Access databases with this version of Visual Studio'. Any other ideas? I'm new with this and need all the help I can get.

Posting Permissions

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