Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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
 
Old January 28th, 2009, 08:19 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Look at this code:
Code:
Dim FILE_NAME AsString = "C:\Templates\" & Me.Label3.Text & ""
Dim objReader AsNew System.IO.StreamReader(FILE_NAME)
Label1.Text = objReader.ReadToEnd
objReader.Close()

i need to bind a column from the database into the Label3 in order for this to work what is the easyest implemantation?

I tryed to use a listbox binde the data into it but cuold not get the listboxvalue into te string: String= C:\Templates\" & ListBox.text &""

__________________
bx
 
Old January 28th, 2009, 08:24 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello. You want to bind a whole collumn? you need to pass several rows to look for several files?
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old January 28th, 2009, 08:54 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

No Just one Record
The tabel i have has 2 columns i am looking like this
:SELECT [Template] FROM [Campaign] WHERE ([CampaignName] = @CampaignName)
so whenever it findes the record it pulls it out this works with listBox,DropDownList,GridView controls, but i ned to use a label or textbox controll
because i dont knoow how to use the value of ListBox control on page load whithout select in it
__________________
bx
 
Old January 30th, 2009, 07:56 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Code:
Dim objConn AsNew SqlConnection("Data Source")
Dim objCmd AsNew SqlCommand("SELECT Template FROM Campaign WHERE (CampaignName = @CampaignName)")
objCmd.Parameters.Add("@CampaignName", Data.SqlDbType.VarChar, 50).Value = Me.lblCampaign.Text
objCmd.CommandType = CommandType.Text
Dim objReader As SqlDataReader
Dim strText AsString
objCmd.Connection = objConn
objConn.Open()
objReader = objCmd.ExecuteReader()
If objReader.Read() Then
objReader.Read()
strText = objReader.Read
Else
strText = "No Template in database."
EndIf
Me.Label3.Text = strText
objConn.Close()
objCmd.Dispose()
objConn.Dispose()
This code works fine if i want to count the rows but it does not binde the actual value,
can any one tell me how to make it work?

Thanks
__________________
bx
 
Old January 30th, 2009, 08:03 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello. I think you are using the wrong words here. Bind is to give a property control a direct access to something in your program. It's remainds for all the program.

Maybe you only want to display the result in a textbox??

Every time you do READ, you are looking for the next row in the dataset. If you want to know the value, look for the column you need inside the reader and you will be find.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old January 30th, 2009, 08:50 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Hi You are wright i just need to Display the value,
Can you please give me a bit of a sample code cos now my mind is not in the wright place, been strangling all morning,

thanks for your replay
__________________
bx
 
Old January 30th, 2009, 09:31 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

thanks it did help a lot i did it.
i used SqlDataAdapter insted of the data reader
__________________
bx
 
Old February 3rd, 2009, 07:37 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

hi I need to update a table in a databse i use this:
Code:
Dim con AsNew SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
Dim cmdd AsNew SqlCommand("UPDATE Users SET Message = Test Where Name= @Name")cmdd.Parameters.Add("@Name", Data.SqlDbType.NVarChar, 50).Value = ListBox1.SelectedValue
cmdd.Connection = con
con.Open()
cmdd.ExecuteNonQuery()
con.Close()
every thing works fine but i need to get the value where test is dynamicy from a textbox in the webpage.
i tryed this:
Code:
Dim TextBox AsString
TextBox = TextBox1.Text
Dim con AsNew SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
Dim cmdd AsNew SqlCommand("UPDATE Users SET Message = " & TextBox & " Where Name= @Name")
cmdd.Parameters.Add("@Name", Data.SqlDbType.NVarChar, 50).Value = ListBox1.SelectedValue
cmdd.Connection = con
con.Open()
cmdd.ExecuteNonQuery()
con.Close()

but it did not work i get this when i debug
Invalid column name " test"
thanks
__________________
bx
 
Old February 3rd, 2009, 07:44 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello.
Probably Message is a column of string type (or vchar, or shomething like that). Anyway, strings should be rounded by '.

So, in your case, you have to do

Code:
 dim cmdd as new sqlcommand("update users set message = '" & textbox & "'where name = @name")
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old February 3rd, 2009, 08:06 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

thanks it did work
__________________
bx




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to upload Files using inet controll in VB dadahonde VB How-To 5 April 11th, 2006 11:16 PM
postback of a particular Controll not whole page Raz Muhammad General .NET 1 November 29th, 2004 12:42 PM
Call Script function in server controll qadeerahmad General .NET 1 September 26th, 2004 11:09 PM
Image controll shows icon not pic Raif Access 2 June 22nd, 2004 01:44 PM
Auto update of text box/label Simon Dilley Classic ASP Basics 1 June 6th, 2003 07:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.