M
Mike Walker
Hi,
Im using the asp.net for dummies and im trying to connect to a sql database.
Here is my code:-
<%@Page Explicit="True" Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head></head>
<script runat="server">
Dim Connect as SqlConnection
Dim SQLCmd as SqlCommand
Dim Adapter as SqlDataAdapter
Dim dsTable as DataSet
Connect = New SqlConnection
SQLCmd = New SqlCommand
Adapter = New SqlAdapter
dsTable = New DataSet
ConnectString="Provider=SQLOLEDB;UID=sa;PWD=;Name=TestData;Data
Source=MyServer;initial Catalog=TestDatabase;"
Connect.ConnectionString=ConnectString
SQLCmd.CommandText="Select * from NameTable"
SQLCmd.Connection=Connect
Adapter.SelectCommand = SQLCmd
Adapter.SelectCommand.Connection.Open
Adapter.Fill(dsTable,"MyData")
<asp:datagrid id="MainGrid" runat="server" />
MainGrid.DataSource=dsTable.Tables("MyData")
MainGrid.DataBind
</script>
</html>
However im getting the following error:-
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 11: Dim dsTable as DataSet
Line 12:
Line 13: Connect = New SqlConnection
Line 14: SQLCmd = New SqlCommand
Line 15: Adapter = New SqlAdapter
Source File: c:\inetpub\wwwroot\testweb\test.aspx Line: 13
what am i doing wrong ?
Note:-
I know im using the long way round DIM, i know I can use :-
Dim Connect as SqlConnection = New New SqlConnection
But I thought I would use the long way until i understand how its working,
or is this where im going wrong ?
Thanks
Mike
(Please do not reply to this email address)
Im using the asp.net for dummies and im trying to connect to a sql database.
Here is my code:-
<%@Page Explicit="True" Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head></head>
<script runat="server">
Dim Connect as SqlConnection
Dim SQLCmd as SqlCommand
Dim Adapter as SqlDataAdapter
Dim dsTable as DataSet
Connect = New SqlConnection
SQLCmd = New SqlCommand
Adapter = New SqlAdapter
dsTable = New DataSet
ConnectString="Provider=SQLOLEDB;UID=sa;PWD=;Name=TestData;Data
Source=MyServer;initial Catalog=TestDatabase;"
Connect.ConnectionString=ConnectString
SQLCmd.CommandText="Select * from NameTable"
SQLCmd.Connection=Connect
Adapter.SelectCommand = SQLCmd
Adapter.SelectCommand.Connection.Open
Adapter.Fill(dsTable,"MyData")
<asp:datagrid id="MainGrid" runat="server" />
MainGrid.DataSource=dsTable.Tables("MyData")
MainGrid.DataBind
</script>
</html>
However im getting the following error:-
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 11: Dim dsTable as DataSet
Line 12:
Line 13: Connect = New SqlConnection
Line 14: SQLCmd = New SqlCommand
Line 15: Adapter = New SqlAdapter
Source File: c:\inetpub\wwwroot\testweb\test.aspx Line: 13
what am i doing wrong ?
Note:-
I know im using the long way round DIM, i know I can use :-
Dim Connect as SqlConnection = New New SqlConnection
But I thought I would use the long way until i understand how its working,
or is this where im going wrong ?
Thanks
Mike
(Please do not reply to this email address)