|
I have created a separate ASP.net page that contains a function for the connectionstring for SQL Server. It is not working. Here's some of my code:
'--------------------------------------------- ' name: BindDataList() '--------------------------------------------- Sub BindDataList()
Dim strConnect As String Dim objConnect As New System.Data.SqlClient.SQLConnection(ConnectionString()) Dim objCommand As New System.Data.SqlClient.SQLCommand Dim strSQL As String Dim dtaSpa As New System.Data.SqlClient.SQLDataAdapter() Dim dtsSpa As New DataSet() Dim strAreaID As String objConnect.Open() 'Get incoming querystring values strAreaID = request.params("AreaID")
'Start SQL statement strSQL = "Select * From SpaStore" 'Add Order By strSQL = strSQL & " where AreaID = '" & strAreaID & "'" strSQL= strSQL & " and ListingType IN ('Featured','National')" strSQL = strSQL & " and Approve=1"
strSQL = strSQL & " Order By SpaStoreName"
'Set the Command Object properties objCommand.Connection = objConnect objCommand.CommandType = CommandType.Text objCommand.CommandText = strSQL
'Create a new DataAdapter object dtaSpa.SelectCommand = objCommand
'Get the data from the database and 'put it into a DataTable object named dttSpa in the DataSet object dtaSpa.Fill(dtsSpa, "dttSpa")
'Set the DataSource property of the DataGrid dtlSpa.DataSource = dtsSpa
'Bind all the controls on the page dtlSpa.DataBind() objCommand.ExecuteNonQuery() 'this is the way to close commands objCommand.Connection.Close() objConnect.Close()
End Sub
'----------------------------------------------------- ' END OF CODE. START OF HTML '-----------------------------------------------------
<!--#include file="SQLServer_Include.aspx"-->
</script>
Here's my code for SQLServer_Include.aspx:
<%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQLClient" %>
<script runat="server">
'================================================================
Private Function ConnectionString () as String
Dim servername, username, password, databasename As String
servername = ""
username = ""
password = ""
databasename = ""
Dim conString As String
conString = conString.Format("server={0};User ID={1};Password={2};Database={3};", servername, username, password, databasename)
Return conString
End Function
</script>
I am getting the following error message:
Parser Error Message: Server includes are not allowed in server script tags.
Source Error:
Line 216:'-----------------------------------------------------
Line 217:
Line 218: <!--#include file="SQLServer_Include.aspx"-->
|
Can someone please help me with this?
|