473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

please help

I am trying to learn asp.net and build a site and i am using web matrix and
vb.net.

I have installed the MSDE on my windows xp pro, i am using the book
calledbeginning dynamic websites with asp.net web matrix.

My problem is the following:

in the book it talks about connectiong to the PUBS database and i know sql
programming and have worked with sql server but i dont see the pubs database
nor Northwind.

#2 im following the example in the book and building a guestbook and i have
set debug="true" get the following error:

myCommand.Fill(ds)

and it says sql connection has not initialized

please look at this snippet and help me and tell me why its not working when
im not even setting up the strings /web matrix is...

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then

' Databind the data grid on the first request only
' (on postback, rebind only in paging and sorting commands)

BindGrid()

End If

End Sub

Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)

DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()

End Sub

Sub DataGrid_Sort(Sender As Object, e As DataGridSortCommandEventArgs)

DataGrid1.CurrentPageIndex = 0
SortField = e.SortExpression
BindGrid()

End Sub
'---------------------------------------------------------
'
' Helpers
'
' use a property to keep track of the sort field, and
' save it in viewstate between postbacks

Property SortField() As String

Get
Dim o As Object = ViewState("SortField")
If o Is Nothing Then
Return String.Empty
End If
Return CStr(o)
End Get

Set(ByVal Value As String)
ViewState("SortField") = Value
End Set

End Property

Sub BindGrid()

' TODO: update the ConnectionString value for your application
Dim ConnectionString As String =
"server=(local);database=master;trusted_connection =true"
Dim CommandText As String

' TODO: update the CommandText value for your application
If SortField = String.Empty Then
CommandText = "select Author, Subject, Message, postedDate" & _
"from guestbookentries order by postedDate desc"
Else
CommandText = "select Author, Subject, Message, postedDate" & _
"from guestbookentries order by " & SortField
End If

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("g uestbookentries"))
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

DataGrid1.DataSource = ds
DataGrid1.DataBind()

End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Data Report with Paging and Sorting
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server"
AutoGenerateColumns="False" width="80%" CellSpacing="1" GridLines="None"
CellPadding="3" BackColor="White" ForeColor="Black"
OnPageIndexChanged="DataGrid_Page" PageSize="6" AllowPaging="True"
OnSortCommand="DataGrid_Sort" AllowSorting="True">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="#4A3C8C"></HeaderStyle>
<PagerStyle horizontalalign="Right" backcolor="#C6C3C6"
mode="NumericPages"></PagerStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
<Columns>
<asp:TemplateColumn SortExpression="Author"
HeaderText="Author">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Author")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Subject"
HeaderText="Subject">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Subject") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Message"
HeaderText="Message">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Message") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="PostedDate"
HeaderText="postedDate">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label
<%# Container.DataItem("postedDate")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</html>

Thanks for your help from this poor programmer
Nov 21 '05 #1
3 1719
The sample SQL Server databases are not installed with MSDE. You need to run
the install scripts for Pubs and Northwind.

You can download these from here
http://www.microsoft.com/downloads/d...displaylang=en
"ntexchange05" wrote:
I am trying to learn asp.net and build a site and i am using web matrix and
vb.net.

I have installed the MSDE on my windows xp pro, i am using the book
calledbeginning dynamic websites with asp.net web matrix.

My problem is the following:

in the book it talks about connectiong to the PUBS database and i know sql
programming and have worked with sql server but i dont see the pubs database
nor Northwind.

#2 im following the example in the book and building a guestbook and i have
set debug="true" get the following error:

myCommand.Fill(ds)

and it says sql connection has not initialized

please look at this snippet and help me and tell me why its not working when
im not even setting up the strings /web matrix is...

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then

' Databind the data grid on the first request only
' (on postback, rebind only in paging and sorting commands)

BindGrid()

End If

End Sub

Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)

DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()

End Sub

Sub DataGrid_Sort(Sender As Object, e As DataGridSortCommandEventArgs)

DataGrid1.CurrentPageIndex = 0
SortField = e.SortExpression
BindGrid()

End Sub
'---------------------------------------------------------
'
' Helpers
'
' use a property to keep track of the sort field, and
' save it in viewstate between postbacks

Property SortField() As String

Get
Dim o As Object = ViewState("SortField")
If o Is Nothing Then
Return String.Empty
End If
Return CStr(o)
End Get

Set(ByVal Value As String)
ViewState("SortField") = Value
End Set

End Property

Sub BindGrid()

' TODO: update the ConnectionString value for your application
Dim ConnectionString As String =
"server=(local);database=master;trusted_connection =true"
Dim CommandText As String

' TODO: update the CommandText value for your application
If SortField = String.Empty Then
CommandText = "select Author, Subject, Message, postedDate" & _
"from guestbookentries order by postedDate desc"
Else
CommandText = "select Author, Subject, Message, postedDate" & _
"from guestbookentries order by " & SortField
End If

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("g uestbookentries"))
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

DataGrid1.DataSource = ds
DataGrid1.DataBind()

End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Data Report with Paging and Sorting
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server"
AutoGenerateColumns="False" width="80%" CellSpacing="1" GridLines="None"
CellPadding="3" BackColor="White" ForeColor="Black"
OnPageIndexChanged="DataGrid_Page" PageSize="6" AllowPaging="True"
OnSortCommand="DataGrid_Sort" AllowSorting="True">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="#4A3C8C"></HeaderStyle>
<PagerStyle horizontalalign="Right" backcolor="#C6C3C6"
mode="NumericPages"></PagerStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
<Columns>
<asp:TemplateColumn SortExpression="Author"
HeaderText="Author">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Author")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Subject"
HeaderText="Subject">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Subject") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Message"
HeaderText="Message">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Message") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="PostedDate"
HeaderText="postedDate">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label
<%# Container.DataItem("postedDate")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</html>

Thanks for your help from this poor programmer

Nov 21 '05 #2
Thank you so very much for answering my question, could you please explain
to me why my code fails when it is generated by the web matrix software?
thanks again ..and god bless
"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:17**********************************@microsof t.com...
The sample SQL Server databases are not installed with MSDE. You need to run the install scripts for Pubs and Northwind.

You can download these from here:
http://www.microsoft.com/downloads/d...displaylang=en

"ntexchange05" wrote:
I am trying to learn asp.net and build a site and i am using web matrix and vb.net.

I have installed the MSDE on my windows xp pro, i am using the book
calledbeginning dynamic websites with asp.net web matrix.

My problem is the following:

in the book it talks about connectiong to the PUBS database and i know sql programming and have worked with sql server but i dont see the pubs database nor Northwind.

#2 im following the example in the book and building a guestbook and i have set debug="true" get the following error:

myCommand.Fill(ds)

and it says sql connection has not initialized

please look at this snippet and help me and tell me why its not working when im not even setting up the strings /web matrix is...

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then

' Databind the data grid on the first request only
' (on postback, rebind only in paging and sorting commands)

BindGrid()

End If

End Sub

Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()

End Sub

Sub DataGrid_Sort(Sender As Object, e As DataGridSortCommandEventArgs)
DataGrid1.CurrentPageIndex = 0
SortField = e.SortExpression
BindGrid()

End Sub
'---------------------------------------------------------
'
' Helpers
'
' use a property to keep track of the sort field, and
' save it in viewstate between postbacks

Property SortField() As String

Get
Dim o As Object = ViewState("SortField")
If o Is Nothing Then
Return String.Empty
End If
Return CStr(o)
End Get

Set(ByVal Value As String)
ViewState("SortField") = Value
End Set

End Property

Sub BindGrid()

' TODO: update the ConnectionString value for your application
Dim ConnectionString As String =
"server=(local);database=master;trusted_connection =true"
Dim CommandText As String

' TODO: update the CommandText value for your application
If SortField = String.Empty Then
CommandText = "select Author, Subject, Message, postedDate" & _ "from guestbookentries order by postedDate desc"
Else
CommandText = "select Author, Subject, Message, postedDate" & _ "from guestbookentries order by " & SortField
End If

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("g uestbookentries"))
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

DataGrid1.DataSource = ds
DataGrid1.DataBind()

End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>Data Report with Paging and Sorting
</h2>
<hr size="1" />
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server"
AutoGenerateColumns="False" width="80%" CellSpacing="1" GridLines="None"
CellPadding="3" BackColor="White" ForeColor="Black"
OnPageIndexChanged="DataGrid_Page" PageSize="6" AllowPaging="True"
OnSortCommand="DataGrid_Sort" AllowSorting="True">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="#4A3C8C"></HeaderStyle>
<PagerStyle horizontalalign="Right" backcolor="#C6C3C6"
mode="NumericPages"></PagerStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
<Columns>
<asp:TemplateColumn SortExpression="Author"
HeaderText="Author">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Author")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Subject"
HeaderText="Subject">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Subject") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Message"
HeaderText="Message">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label

<%# Container.DataItem("Message") %>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="PostedDate"
HeaderText="postedDate">
<EditItemTemplate>
<asp:Label id="Label1" runat="server">Label
<%# Container.DataItem("postedDate")%>
</asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</html>

Thanks for your help from this poor programmer

Nov 21 '05 #3
nTextChange,

If you have VisualStudio Net there is in my opinion not any reason to use
Matrix. Matrix looks at least as a subset of VisualStudio Net

The design part from AspNet in Visual.Studio Net before 2005 is real weak.

Therefore you can (if you are not somebody who uses direct HTML) go for a
more Webpage designer program beside that.

I hope this gives an idea

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
13
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
0
by: 2Barter.net | last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA Inbox Reply Reply to all Forward Print Add 2Barter.net to Contacts list Delete this message Report phishing Show original
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
5
by: tabani | last post by:
I wrote the program and its not giving me correct answer can any one help me with that please and specify my mistake please it will be highly appreciable... The error arrives from option 'a' it asks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.