D
D. Shane Fowlkes
Still learning ASP.NET....(and I was getting so good with classic ASP too!).
I'm trying to connect to a SQL Server using a simple connection script.
I've checked 2 different books and looked at www.asp.net and still cannot
get past this "error".
Can anyone see the error? This <script> example is almost line by line from
the Sams ASP.NET Unleashed Book. The error is on line 8. Thanks.
Compiler Error Message: BC30188: Declaration expected.
Source Error:
Line 8: DbConn = New SQLConnection("server=drpt-server3;
database=DRPT-TEST")
**********************************
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim DbConn As SQLConnection
Dim MySQLCommand As SQLCommand
Dim RS As SQLDataReader
DbConn = New SQLConnection("server=drpt-server3; database=DRPT-TEST")
DbConn.Open()
MySQLCommand = New MySQLCommand("SELECT * FROM Staff;", DbConn)
RS = MySQLCommand.ExecuteReader()
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body>
<%
RS.MoveFirst
Response.Write RS("LastName").Value
DbConn.Close()
RS.Close()
%>
</body>
</html>
--
*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************
I'm trying to connect to a SQL Server using a simple connection script.
I've checked 2 different books and looked at www.asp.net and still cannot
get past this "error".
Can anyone see the error? This <script> example is almost line by line from
the Sams ASP.NET Unleashed Book. The error is on line 8. Thanks.
Compiler Error Message: BC30188: Declaration expected.
Source Error:
Line 8: DbConn = New SQLConnection("server=drpt-server3;
database=DRPT-TEST")
**********************************
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim DbConn As SQLConnection
Dim MySQLCommand As SQLCommand
Dim RS As SQLDataReader
DbConn = New SQLConnection("server=drpt-server3; database=DRPT-TEST")
DbConn.Open()
MySQLCommand = New MySQLCommand("SELECT * FROM Staff;", DbConn)
RS = MySQLCommand.ExecuteReader()
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body>
<%
RS.MoveFirst
Response.Write RS("LastName").Value
DbConn.Close()
RS.Close()
%>
</body>
</html>
--
*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************