声明预期? [英] Declaration Expected?

查看:92
本文介绍了声明预期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还在学习ASP.NET ....(而且我在使用经典ASP的过程中也做得很好!)。


我正在尝试连接到SQL Server一个简单的连接脚本。

我检查了两本不同的书并查看了 www.asp.net 仍然无法

超过此错误。


任何人都可以看到错误吗?这个<脚本>示例几乎是从Sams ASP.NET Unleashed Book中逐行排列的。错误在第8行。谢谢。


编译器错误消息:BC30188:预期声明。


源错误:


第8行:DbConn =新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 =新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")。值


DbConn.Close()

RS.Close()

%>

< / body>

< / html>


-

*************** ******************

D. Shane Fowlkes - TMM

一次拯救世界,一个网站。
http:// www .shanefowlkes.com

*********************************

解决方案

错误是什么?

-----原始信息 - ---
还在学习ASP.NET ....(而且我用
经典ASP也好了!)。
我正在尝试连接到SQL Server使用一个简单的
连接脚本。我检查过2本不同的书籍并查看了 www.asp。 net
仍然无法通过此错误。

任何人都可以看到错误吗?这个<脚本>例如,几乎是来自Sams ASP.NET Unleashed Book的
。错误在线
8.谢谢。

编译错误消息:BC30188:预期声明。

来源错误:

线8:DbConn =新SQLConnection(server = drpt-server3;
数据库= DRPT-TEST)

**************** ******************

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

< script runat =" server">
Dim DbConn As SQLConnection
Dim MySQLCommand As SQLCommand
Dim RS As SQLDataReader

DbConn =新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)。值。

DbConn.Close()
RS.Close()
%>
< / body>
< / html>

-

******* ************************** *
D. Shane Fowlkes - TMM
一次拯救世界,一个网站。
http ://www.shanefowlkes.com
********************************* br />



嗯...


您是否尝试过放入RS.Read在RS.MoveFirst之后?


此外,一旦你掌握了DataReaders,你可能会考虑放弃它们以支持DataSet。更好。


另外 - 不要忘记DbConn.Dispose()

问候,

Anth

D。 Shane Fowlkes < SH *** @ raccoonbob.com>在消息中写道

新闻:O6 ************** @ TK2MSFTNGP12.phx.gbl ...

仍在学习ASP.NET ....(我的经典ASP
也变得非常好!)。
我正在尝试使用简单的连接脚本连接到SQL Server。
我是'检查了2本不同的书并查看了 www.asp.net 但仍然无法使用
越过这个错误。

任何人都可以看到错误吗?这个<脚本>示例几乎是Sams ASP.NET Unleashed Book中的逐行
。错误在第8行。谢谢。

编译器错误消息:BC30188:预期声明。

来源错误:

第8行:DbConn =新的SQLConnection(server = drpt-server3;
数据库= DRPT-TEST)

******************** **************

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

< script runat =" server">
Dim DbConn As SQLConnection
Dim MySQLCommand As SQLCommand
Dim RS As SQLDataReader

DbConn =新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)。值。

DbConn.Close()
RS.Close()
%>
< / body>
< / html>

-

******* ************************** *
D. Shane Fowlkes - TMM
一次拯救世界,一个网站。
http://www.shanefowlkes.com
*********************************



我把它包含在我的帖子里。


Thx

-

********************************* />
D. Shane Fowlkes - TMM

一次拯救世界,一个网站。
http://www.shanefowlkes.com

****************** ***************

" Jon Paugh" <一个******* @ discussions.microsoft.com>在消息中写道

news:26 **************************** @ phx.gbl ... < blockquote class =post_quotes>错误是什么?

-----原始消息-----
仍在学习ASP.NET ....(


经典的ASP也是如此之好!)。


我正在尝试使用简单的
连接脚本。

我检查了2本不同的书,看了 www.asp.net


仍然无法

过去这个错误。

任何人都可以看到错误?这个<脚本>示例是


几乎逐行来自

Sams ASP.NET Unleashed Book。错误在线


8.谢谢。



编译器错误消息:BC30188:预期声明。

来源错误:

第8行:DbConn =新SQLConnection(server = drpt-server3;
数据库= DRPT-TEST)

**** **********************************

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

< script runat =" server">
Dim DbConn As SQLConnection
Dim MySQLCommand As SQLCommand
Dim RS As SQLDataReader

DbConn =新SQLConnection(" server = drpt-server3;


数据库= DRPT-TEST")

DbConn.Open()

MySQLCommand = New MySQLCommand(" SELECT * FROM Staff;",


DbConn)

RS = MySQLCommand.ExecuteReader()
< /脚本>

< html xmlns =" http://www.w3.org/1999/xhtml">
< head>
< title>无标题文件< / title>
< / head>
< body>
<%
RS.MoveFirst
Response.Write RS(" LastName") .Value

DbConn.Close()
RS.Close()
%>
< / body>
< / html>

-

*********************************
D. Shane Fowlkes - TMM
一次拯救世界,一个网站。
http ://www.shanefowlkes.com
********************************* br />



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
*********************************

解决方案

what is the error?

-----Original Message-----
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 cannotget past this "error".

Can anyone see the error? This <script> example is almost line by line fromthe 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
*********************************

.



Hmm...

Have you tried putting RS.Read after RS.MoveFirst?

Also, once you''re getting good with DataReaders, you might want to consider
ditching them in favour of DataSets. Much nicer.

Also - DON''T forget to DbConn.Dispose()
Regards,
Anth

"D. Shane Fowlkes" <sh***@raccoonbob.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...

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 included it in my post.

Thx

--
*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************
"Jon Paugh" <an*******@discussions.microsoft.com> wrote in message
news:26****************************@phx.gbl...

what is the error?

-----Original Message-----
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
*********************************

.



这篇关于声明预期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆