By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

error: Declaration expected

P: n/a
Hi,

When executing this (asp.net 2.0), i get the error:
Compiler Error Message: BC30188: Declaration expected.
Line 9: Dim dtreader As SqlDataReader
Line 10:
Line 11: db = new Sqlconnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta
Source=D:\access\nemi.mdb")
Line 12:
Line 13:
Source File: D:\Inetpub\wwwroot\aspnet\Begin\Chapter07\access2. aspx Line:
11

but db is declared with: Dim db As SqlConnection??
Thanks
Phil

This is the code:
<%@ Page Language="VB" %>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.SqlClient"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim db As SqlConnection
Dim comm As SqlCommand
Dim dtreader As SqlDataReader
db = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta
Source=D:\access\nemi.mdb")
</script>
May 8 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You have to put the code inside a method.

phil wrote:
Hi,

When executing this (asp.net 2.0), i get the error:
Compiler Error Message: BC30188: Declaration expected.
Line 9: Dim dtreader As SqlDataReader
Line 10:
Line 11: db = new Sqlconnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta
Source=D:\access\nemi.mdb")
Line 12:
Line 13:
Source File: D:\Inetpub\wwwroot\aspnet\Begin\Chapter07\access2. aspx Line:
11

but db is declared with: Dim db As SqlConnection??
Thanks
Phil

This is the code:
<%@ Page Language="VB" %>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.SqlClient"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim db As SqlConnection
Dim comm As SqlCommand
Dim dtreader As SqlDataReader
db = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta
Source=D:\access\nemi.mdb")
</script>

May 8 '06 #2

P: n/a
Thanks

"Göran Andersson" <gu***@guffa.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
You have to put the code inside a method.

phil wrote:
Hi,

When executing this (asp.net 2.0), i get the error:
Compiler Error Message: BC30188: Declaration expected.
Line 9: Dim dtreader As SqlDataReader
Line 10:
Line 11: db = new Sqlconnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\access\nemi.mdb")
Line 12:
Line 13:
Source File: D:\Inetpub\wwwroot\aspnet\Begin\Chapter07\access2. aspx Line: 11

but db is declared with: Dim db As SqlConnection??
Thanks
Phil

This is the code:
<%@ Page Language="VB" %>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.SqlClient"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim db As SqlConnection
Dim comm As SqlCommand
Dim dtreader As SqlDataReader
db = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Da ta
Source=D:\access\nemi.mdb")
</script>

May 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.