dcsimg
Results 1 to 7 of 7

Thread: .net connection with SQL server express

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    18

    .net connection with SQL server express

    Hi,

    could anyone tell me why i'm getting the following error from the code below:

    Error Type:
    Active Server Pages, ASP 0221 (0x80004005)
    The specified 'Import Namespace="System.Data.OleDb" ' option is unknown or invalid.
    /default.asp, line 6


    HTML Code:
    <html>
    <body>
    
    <%@ Import Namespace="System.Data.OleDb" %>
    
    <script runat="server">
    sub Page_Load
    dim dbconn
    dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
    data source=" & server.mappath("PC28434DXPA\SQLEXPRESS\retro"))
    dbconn.Open()
    end sub
    </script>
    
    <table border="1" width="100%">
    <%do until rs.EOF%>
      <tr>
      <%for each x in rs.Fields%>
        <td><%Response.Write(x.value)%></td>
      <%next
      rs.MoveNext%>
      </tr>
    <%loop
    rs.close
    conn.close
    %>
    </table>
    
    
    
    
    </body>
    </html>
    Twitter @dancematt

    Programmers unite

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: .net connection with SQL server express

    You have to use the aspx extension.

    Take the line break out of your dbconn line.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    18

    Re: .net connection with SQL server express

    ive implemented the changes and now it reads the Server Application Unavailable.

    Do I need an ODBC driver for SQL server express 2008?
    Twitter @dancematt

    Programmers unite

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,302

    Re: .net connection with SQL server express

    You should be using the SQLClient provider rather than either OleDB or ODBC when connecting to SQL Server. However, I would note that I work in WinForms, so ASP may be different.
    My usual boring signature: Nothing

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,563

    Re: .net connection with SQL server express

    Umm... no... ugh... you should be using the SQLClient namespace... why are you trying to use ODBC? Your data connection is 12 ways to Sunday wrong... there's no need for the mappath...
    Here... this is the one you should be using... http://connectionstrings.com/sql-server-2008#p1

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: .net connection with SQL server express

    Quote Originally Posted by techgnome View Post
    Umm... no... ugh... you should be using the SQLClient namespace... why are you trying to use ODBC? Your data connection is 12 ways to Sunday wrong... there's no need for the mappath...
    Here... this is the one you should be using... http://connectionstrings.com/sql-server-2008#p1

    -tg
    I'm assuming he's following a tutorial like: http://www.w3schools.com/aspnet/aspnet_dbconnection.asp

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    18

    Re: .net connection with SQL server express

    Quote Originally Posted by MattP View Post
    I'm assuming he's following a tutorial like: http://www.w3schools.com/aspnet/aspnet_dbconnection.asp
    Exactly that tutorial yea haha

    Would anyone be so kind as to show my how to implement the correct connection?
    Twitter @dancematt

    Programmers unite

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width