I want to connect sql database via ado.net but error is encounter as shown
as below:


Compilation Error
=================
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:
=============
Line 7: Dim myCommand As SqlCommand = New SqlCommand("select * from
gldate", myConnection)
Line 8:
Line 9: myConnection.Open()
Line 10:
Line 11:



Show Detailed Compiler Output:
==============================
myConnection.Open()
~~~~~~~~~~~~
D:\SQLDB\Intranet\WebApp\Finance\subsystem\gl\dropdownlist.aspx(15) : error
BC30188: Declaration expected.

myConnection.Close()
~~~~~~~~~~~~


find.aspx
=========
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">

Dim myConnection As SqlConnection = New
SqlConnection("server=(sql01);database=ERP_ARCHIVAL;user
id=intranet;password=intranet")
Dim myCommand As SqlCommand = New SqlCommand("select * from gldate",
myConnection)

myConnection.Open()


Dim dr As SqlDataReader = myCommand.ExecuteReader()


myConnection.Close()

</script>
<html>
<head>
<title>Intranet Information System</title>
</head>
<body>
<form runat="server">
<asp:DropDownList id="DropDownList1"
runat="server"></asp:DropDownList>
</form>
</body>
</html>


Please help.

Re: SQLconnection? by Miha

Miha
Fri Feb 18 02:13:03 CST 2005

Sounds to me like you've never declared myConnection variable (althoug there
i see the declaration).
Try commenting all the code and then uncomment line by line and see what
happens.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Sam" <cybersam88@hotmail.com> wrote in message
news:%23U$bU9YFFHA.3824@TK2MSFTNGP10.phx.gbl...
>I want to connect sql database via ado.net but error is encounter as shown
>as below:
>
>
> Compilation Error
> =================
> Description: An error occurred during the compilation of a resource
> required to service this request. Please review the following specific
> error details and modify your source code appropriately.
>
> Compiler Error Message: BC30188: Declaration expected.
>
> Source Error:
> =============
> Line 7: Dim myCommand As SqlCommand = New SqlCommand("select * from
> gldate", myConnection)
> Line 8:
> Line 9: myConnection.Open()
> Line 10:
> Line 11:
>
>
>
> Show Detailed Compiler Output:
> ==============================
> myConnection.Open()
> ~~~~~~~~~~~~
> D:\SQLDB\Intranet\WebApp\Finance\subsystem\gl\dropdownlist.aspx(15) :
> error BC30188: Declaration expected.
>
> myConnection.Close()
> ~~~~~~~~~~~~
>
>
> find.aspx
> =========
> <%@ Page Language="VB" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
> <script runat="server">
>
> Dim myConnection As SqlConnection = New
> SqlConnection("server=(sql01);database=ERP_ARCHIVAL;user
> id=intranet;password=intranet")
> Dim myCommand As SqlCommand = New SqlCommand("select * from gldate",
> myConnection)
>
> myConnection.Open()
>
>
> Dim dr As SqlDataReader = myCommand.ExecuteReader()
>
>
> myConnection.Close()
>
> </script>
> <html>
> <head>
> <title>Intranet Information System</title>
> </head>
> <body>
> <form runat="server">
> <asp:DropDownList id="DropDownList1"
> runat="server"></asp:DropDownList>
> </form>
> </body>
> </html>
>
>
> Please help.
>



Re: SQLconnection? by Cor

Cor
Fri Feb 18 03:06:49 CST 2005

Sam,

You can try with setting an try block in your code.

Something as
Try
connection.open
Catch ex as exception
response.redirect(ex.tostring)
End try

Mostly you get than more information.

I hope this helps.

Cor



SQLconnection? by Elton

Elton
Fri Feb 18 14:13:02 CST 2005

You may need to use Imports rather than Import in

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

HTH

Elton Wang
elton_wang@hotmail.com


>-----Original Message-----
>I want to connect sql database via ado.net but error is
encounter as shown
>as below:
>
>
>Compilation Error
>=================
>Description: An error occurred during the compilation of
a resource required
>to service this request. Please review the following
specific error details
>and modify your source code appropriately.
>
>Compiler Error Message: BC30188: Declaration expected.
>
>Source Error:
>=============
>Line 7: Dim myCommand As SqlCommand = New SqlCommand
("select * from
>gldate", myConnection)
>Line 8:
>Line 9: myConnection.Open()
>Line 10:
>Line 11:
>
>
>
>Show Detailed Compiler Output:
>==============================
>myConnection.Open()
>~~~~~~~~~~~~
>D:\SQLDB\Intranet\WebApp\Finance\subsystem\gl\dropdownlist
.aspx(15) : error
>BC30188: Declaration expected.
>
>myConnection.Close()
>~~~~~~~~~~~~
>
>
>find.aspx
>=========
><%@ Page Language="VB" %>
><%@ Import Namespace="System.Data" %>
><%@ Import Namespace="System.Data.SqlClient" %>
><script runat="server">
>
>Dim myConnection As SqlConnection = New
>SqlConnection("server=(sql01);database=ERP_ARCHIVAL;user
>id=intranet;password=intranet")
>Dim myCommand As SqlCommand = New SqlCommand("select *
from gldate",
>myConnection)
>
>myConnection.Open()
>
>
>Dim dr As SqlDataReader = myCommand.ExecuteReader()
>
>
>myConnection.Close()
>
></script>
><html>
><head>
> <title>Intranet Information System</title>
></head>
><body>
> <form runat="server">
> <asp:DropDownList id="DropDownList1"
>runat="server"></asp:DropDownList>
> </form>
></body>
></html>
>
>
>Please help.
>
>
>.
>