473,387 Members | 1,440 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,387 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 1716
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.