473,320 Members | 1,921 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,320 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 1712
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.