 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 9th, 2007, 02:37 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
quote:but havent i forgot something like Eval("SiteMainText")
|
That's possible, but hard for me to judge as I don't know your pages. So, maybe the SqlDataSource does fire, but you don't do anything with it?
Try adding a data control (like a GridView) to the page and attach it to the SqlDataSource with its DataSourceID property and see if you get any results. Then you can see if the query returns data or not and work from there.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

January 9th, 2007, 06:01 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
nothing happens when i do like u write about the breakline. hmm !!?
if i want to use old asp code as i know like:
Dim strTitle, strText
strSQL = "SELECT [TextOverskrift], [TextMain] FROM index"
strSQL = strSQL & " WHERE [TextID] = 1"
Set objRS = objConn.Execute(strSQL)
If Not (objRS.BOF Or objRS.EOF) Then
Response.Write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>")
Do While Not objRS.EOF
strTitle = objRS("TextOverskrift")
strText = objRS("TextMain")
Response.Write("<tr><td>")
If strTitle <> "" Then
Response.Write("<b>"&strTitle&"</b><br><br>")
Else
Response.Write("")
End If
Response.Write(strText)
Response.Write("</td></tr>")
objRS.MoveNext
Loop
Response.Write ("</table>")
else
Response.Write "Der findes intet i Databasen"
End If
and want to use the connection in web.config
<connectionStrings>
<add name="ConnectionStringMain" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\aeronetDSNbase.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
can u then help me making my old asp code work so i can see how i can make it, bc im new in asp.net but asp:datagrid an so on i thing is harder to use then the old code i know.
|
|

January 9th, 2007, 06:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Did you add a GridView that uses the SqlDataSource?
Can you post the code for the ASPX page and its code behind?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Tempel by Opgezwolle (Track 4 from the album: Vloeistof) What's This?
|
|

January 9th, 2007, 06:16 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the hole code is in this post, do u want the master page to !?
Posted - 01/08/2007 : 6:24:42 PM
|
|

January 9th, 2007, 06:18 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Is it?? Then where is the GridView?
The SqlDataSource only retrieves data; you need other controls like the GridView to display it...
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Tempel by Opgezwolle (Track 4 from the album: Vloeistof) What's This?
|
|

January 10th, 2007, 04:07 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar
1000 Thx for ur time, i ende up with this and it work so i can show the data, im also changes it so i use access DB and not MSSQL bc my host can't handel a MSSQL db, now i just have to changes the code to use Request.QueryString("Page").ToString().
<asp:Content ID="Main" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">
<%
Dim rdr As OleDbDataReader = Nothing
Dim con As OleDbConnection = Nothing
Dim cmd As OleDbCommand = Nothing
Try
Dim ConnectionString As String = ConfigurationManager.AppSettings("ConnStr")
con = New OleDbConnection(ConnectionString)
con.Open()
Dim CommandText As String = "SELECT [SiteMa], [SiteMai] FROM [Text] WHERE [SiteMa] = 1"
cmd = New OleDbCommand(CommandText)
cmd.Connection = con
rdr = cmd.ExecuteReader()
Dim strText As String = ""
While rdr.Read()
strText = rdr("SiteMainText").ToString()
Response.Write(strText)
End While
Finally
If Not (rdr Is Nothing) Then
rdr.Close()
End If
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
%>
</asp:Content>
|
|

January 10th, 2007, 04:34 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
While this code certainly works, I can strongly recommend investigating a little more time in the other solution. With your current code, you're not really making use of the new features in .NET. In fact, your code resembles classic ASP quite a lot.
Learning .NET may be hard at first, but once you get the hang of it, you can be really productive with it, without reverting to "old skool" spaghetti code.... ;)
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

January 10th, 2007, 05:28 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i know it :) but work as a TV/Radio sellsman so i have only time for this after work. :'(
|
|

January 10th, 2007, 05:31 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, if it works, it works... ;)
Good luck,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Vraag & Antwoord by Opgezwolle (Track 6 from the album: Vloeistof) What's This?
|
|

January 10th, 2007, 05:40 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Damn U hit me hard, aboud Posted - 01/10/2007 : 8:34:24 PM, and yes now i know how to get it to word, BUT.. :D (if we can look at it just one more time)
I have a content in this content i will only show one record from an Access database, and the record is a long text, how will this code then look like and what grid/repeater do i need to use in this code !?
<asp:Content ID="Main" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringMain %>"
SelectCommand="SELECT [MainID], [MainText] FROM [SiteText] WHERE ([MainID] = @MainID)">
<SelectParameters>
<asp:Parameter Name="MainID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
|
|
 |