I have wrote the program to create the connection with SQL Server. The page executes and doesn't give any error. But it also didn't display the results, the page is blank. The code is this:
<%@ Page Language="
vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.
vb" Inherits="WebApplication1.WebForm1"%>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>
<html>
<head>
<title>WebForm1</title>
</head>
<body>
<asp:DataGrid ID=dgNameList Runat=server
GridLines="None"
BackColor="LightBlue"
Cellpadding="5"
CellSpacing="5"
BorderWidth="2"
BorderColor="Black">
</asp:DataGrid>
</body>
</html>
<script language=
vb runat=server>
Sub Page_Load(Source As object, E as EventArgs)
Dim strCon As String = ConfigurationSettings.AppSettings("NWind")
Dim objCon As New SqlConnection(strCon)
Dim strSQL = "Select FirstName, LastName, Country " & _
"From Employees"
Dim objCommand As new SqlCommand(strSQL, objCon)
objCon.Open()
dgNameList.DataSource = objCommand.ExecuteReader()
dgNameList.DataBind()
objCon.Close()
End Sub
</script>
And in the Web.config file the database connection string is as :
<appSettings>
<add key="NWind"
value="Server=(local)\NetSDK; database=Northwind; integrated security=true;">
</add>
</appSettings>
plz guide me about the problem.