 |
| 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
|
|
|
|

January 28th, 2009, 08:19 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
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
|
|

January 28th, 2009, 08:24 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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.
================================================== =========
|
|

January 28th, 2009, 08:54 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
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
|
|

January 30th, 2009, 07:56 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
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
|
|

January 30th, 2009, 08:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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.
================================================== =========
|
|

January 30th, 2009, 08:50 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
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
|
|

January 30th, 2009, 09:31 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
thanks it did help a lot i did it.
i used SqlDataAdapter insted of the data reader
__________________
bx
|
|

February 3rd, 2009, 07:37 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
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
|
|

February 3rd, 2009, 07:44 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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.
================================================== =========
|
|

February 3rd, 2009, 08:06 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
thanks it did work
__________________
bx
|
|
 |