-
Mar 14th, 2012, 10:02 AM
#1
Thread Starter
Junior Member
.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
-
Mar 14th, 2012, 10:23 AM
#2
Re: .net connection with SQL server express
You have to use the aspx extension.
Take the line break out of your dbconn line.
-
Mar 14th, 2012, 11:35 AM
#3
Thread Starter
Junior Member
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
-
Mar 14th, 2012, 11:40 AM
#4
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
-
Mar 14th, 2012, 11:41 AM
#5
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
-
Mar 14th, 2012, 11:45 AM
#6
Re: .net connection with SQL server express
 Originally Posted by techgnome
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
-
Mar 14th, 2012, 12:18 PM
#7
Thread Starter
Junior Member
Re: .net connection with SQL server express
 Originally Posted by MattP
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|