TCantrell
asked on
Simple Database driven page with .NET
Hi Experts,
I'm a relative newbie and I'm looking for help creating a very simple database driven page. Maximum points given because this is very challenging for me.
I'm creating a webpage for Helpdesk documentation.
I want to create a page that will display links to different Step by Step Solutions stored in a database. I also want to create a page with a form for technicians to enter a Problem and a solution that will be stored and retrieved from the same database. (I've downloaded the MSDE, I also have Access 2000).
I've set up a table in MSSQL database with these columns: Solutions_ID, Solutions_Category, Solutions_Title, Solutions_Solution.
I'm looking a for an example that is as basic and simple as possible.
Thanks for your help.
I'm a relative newbie and I'm looking for help creating a very simple database driven page. Maximum points given because this is very challenging for me.
I'm creating a webpage for Helpdesk documentation.
I want to create a page that will display links to different Step by Step Solutions stored in a database. I also want to create a page with a form for technicians to enter a Problem and a solution that will be stored and retrieved from the same database. (I've downloaded the MSDE, I also have Access 2000).
I've set up a table in MSSQL database with these columns: Solutions_ID, Solutions_Category, Solutions_Title, Solutions_Solution.
I'm looking a for an example that is as basic and simple as possible.
Thanks for your help.
ASKER
And ASP.NET
Sorry, my head is swimming from all the searching.
Sorry, my head is swimming from all the searching.
Probably the easiest thing to do would be to load the data up into a datagrid. You can find a complete set of articles about attaching a Datagrid to a data source here:
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
You may also want to see this article, which describes the Datagrid, Datalist and Repeater objects. You may find one of them to fit your scheme a little better:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-whenusedatawebcontrols.asp
In good conscience, I have to tell you that you are completely wasting your points on this question. This is easily the most dicussed topic on the web, and there are more examples of how to bind to data than any other topic on ASP.NET. But, since you asked for a simple, direct example:
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.Sql Client" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
BindData()
End Sub
Sub BindData()
'1. Create a connection
Dim myConnection as New SqlConnection(
ConfigurationSettings.AppS ettings("c onnectionS tring")) 'This assumes you have connectionstring stored in your web.config file
'2. Create the command object, passing in the SQL string
Const strSQL as String = "SELECT * FROM MyTable"
Dim myCommand as New SqlCommand(strSQL, myConnection)
'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
dgPopularFAQs.DataSource = myCommand.ExecuteReader(
CommandBehavior.CloseConne ction)
dgPopularFAQs.DataBind()
End Sub
</script>
<asp:datagrid id="dgPopularFAQs" runat="server" />
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
You may also want to see this article, which describes the Datagrid, Datalist and Repeater objects. You may find one of them to fit your scheme a little better:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-whenusedatawebcontrols.asp
In good conscience, I have to tell you that you are completely wasting your points on this question. This is easily the most dicussed topic on the web, and there are more examples of how to bind to data than any other topic on ASP.NET. But, since you asked for a simple, direct example:
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.Sql
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
BindData()
End Sub
Sub BindData()
'1. Create a connection
Dim myConnection as New SqlConnection(
ConfigurationSettings.AppS
'2. Create the command object, passing in the SQL string
Const strSQL as String = "SELECT * FROM MyTable"
Dim myCommand as New SqlCommand(strSQL, myConnection)
'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
dgPopularFAQs.DataSource = myCommand.ExecuteReader(
CommandBehavior.CloseConne
dgPopularFAQs.DataBind()
End Sub
</script>
<asp:datagrid id="dgPopularFAQs" runat="server" />
ASKER
Thanks for the answer. I'm going to dive in today.
And thanks for being straight-forward about points.
I have one more question, I'm wanting to store and retrieve lenghty text articles/solutions. Can this be done in a database or is their a limitation as to how many characters a DB field can hold (255?).
Is there a better mechanism for storing text docs?
I'm not looking for a specific answer just a point in the right direction.
Thanks.
And thanks for being straight-forward about points.
I have one more question, I'm wanting to store and retrieve lenghty text articles/solutions. Can this be done in a database or is their a limitation as to how many characters a DB field can hold (255?).
Is there a better mechanism for storing text docs?
I'm not looking for a specific answer just a point in the right direction.
Thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks for the help.
What database do you use for your KB?
What database do you use for your KB?
MS SQL Server 2000. We are a Microsoft shop all around. I like the ability to setup Full Text Search on my articles, and you can't beat the support. But if not a MS shop, or price is a concern for you, I can reccomend both mySQL and FireFox (the DB, not the browser) as good, open source or free alternatives.
ASKER
Thanks toddhd.
ASKER
I also have VB.NET Studio.