473,473 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Display multiple columns in a label

Vkas
78 New Member
Hi to all !

MY Case:


i have created a label
i had a table(Empinfo) for Employee information in SQL server 2000
my Query ="Select Firstname,lastname from Empinfo"
my connection ok!
i get connected and display the values of both the columns in the datagridveiw its ok too and done

My Problem
But i want to display the both the column in that label..
Feb 24 '09 #1
12 4982
alamodgal
38 New Member
hiiiiiiii
Can pls explain what u actually want.You want to display values of two fields of your table in one column of your grid.Is it this that u want?
Feb 24 '09 #2
Vkas
78 New Member
i want
want to display values of two fields of your table in one Label in my page .

i had done it but i want to give space that is being not done any idea

mean
I had a table (empinfo)
had three columns

firstName | Middle Name|Last name|emp id
sara |Ahmed | Gilani | 1
wahaj |ali | khan |2



this type of table
now i had a label control and i want to display (firstname Lastname ) in that label (sara Gilani)

i hope you understand
Feb 24 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
You retrieve the data from the database. When you do this it's stored in some Object. Use that Object to set the Text property of the Label.

For me to better explain what I'm getting at here please post the code you are using to retrieve the data from the database.
Feb 24 '09 #4
alamodgal
38 New Member
hiiiiiiiiiiiiii
You just make ur query like this and fetch name in label like this:



query=select firstname+' '+lastname as name from empinfo


You can give as much space as you want in single quotes.
Feb 25 '09 #5
Vkas
78 New Member
hi Alam!

i have tried your method but it gives me exception
"Index was out of the bound of array"
Feb 25 '09 #6
Vkas
78 New Member
hi farnival i am sending you the code
let me tell you one thing that i had created a class named Database with some function!!!!

My Class Data base code!!
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.SqlClient
  2. Imports Microsoft.VisualBasic
  3.  
  4.  
  5. Public Class Database
  6.     Private Shared mycommand As SqlCommand
  7.     Private Shared dr As SqlDataReader
  8.     Private Shared da As SqlDataAdapter
  9.     Private Shared con As SqlConnection
  10.     Shared Function connection()
  11.         Dim con As SqlConnection = New SqlConnection
  12.         con.ConnectionString = "data source = (local) ; initial catalog = WisHRM ; Integrated Security = SSPI"
  13.         Return con
  14.     End Function
  15.     Shared Sub GetSelectQuery(ByVal query As String)
  16.         con = Database.connection
  17.         con.Open()
  18.         mycommand = New SqlCommand(query, con)
  19.         dr = mycommand.ExecuteReader
  20.         dr.Read()
  21.     End Sub
  22.     Shared Function GetResult()
  23.         Return dr
  24.     End Function
  25.     Shared Sub GetDsQuery(ByVal query As String)
  26.         con = Database.connection
  27.         con.Open()
  28.         da = New SqlDataAdapter(query, con)
  29.     End Sub
  30.     Shared Function GetDsResult()
  31.         Return da
  32.     End Function
  33.     Shared Function GetUpdateQuery(ByVal query As String)
  34.         con = Database.connection
  35.         con.Open()
  36.         Dim i As Integer = 0
  37.         mycommand = New SqlCommand(query, con)
  38.         i = mycommand.ExecuteNonQuery
  39.         Return i
  40.     End Function
  41.  
  42. End Class
  43.  

Now i am calling the function of that class to connect and get result from database!
my Welcome Page

i had a label in it !!

its code
Expand|Select|Wrap|Line Numbers
  1. Database.GetSelectQuery("Select strFirstName,strLastName from tblEmployee where intEmployeeid = 4)
  2.                 lblName.Text = Database.GetResult(0) + Database.GetResult(1)
as i told you i had acheived to show firstname and last name through the code
but the problem now remaining in that is that i cant give space i had tried the Alamodgal method but it gives the same Error !! as i had written!!
Feb 25 '09 #7
alamodgal
38 New Member
Use this code

Database.GetSelectQuery("Select strFirstName+' '+strLastName as name from tblEmployee where intEmployeeid = 4)
lblName.Text = Database.GetResult(0)
Feb 25 '09 #8
Vkas
78 New Member
thankkkss thankkssss
Alam!
wawooo!!
this is the first 100% solved problem of mine from internet in which it worked 100% right

i am very great full to u !

you are here new but seems to have very much more experience
Feb 25 '09 #9
alamodgal
38 New Member
hiiiiiiiiiiii
Its ok.
Ya im new here but not much experienced.
Feb 25 '09 #10
Vkas
78 New Member
yapp hahahah
but more experience than me
Feb 25 '09 #11
Vkas
78 New Member
do u have any idea of web user control
Feb 25 '09 #12
alamodgal
38 New Member
ya whats ur problem in that
Feb 25 '09 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
2
by: Niks | last post by:
Hi, I have just now installed VS.NET on my system and created basic .aspx files using <asp:label id="Message1" font-size="16" font-bold="true" forecolor="red" runat=server>Test</asp:label> tags...
4
by: Joe Van Meer | last post by:
Hi, Is the datalist meant for one table or can I use it to display information from 2 different tables? Or should I be looking at a datagrid instead? I began my code and kinda ran into a snag...
2
by: Stephen | last post by:
Hi, Can a datagrid display be split into 2 rows. for e.g: suppose my resultset has 20 columns and I want to display 10 in the first row and and rest in another so that the display is not kludgy....
2
by: Joe Campbell | last post by:
I have a DBA that wrote a stored procedure that does a SELECT from a particluar SQL Server table. Within that stored procedure he links over to grab a column from another database table. I need to...
0
by: Linta | last post by:
Hi, Actually i want to display mutiple images using BinaryWrite method. I am able to store all the images in an object.My problem is that i couldnt display all that images in the browser. I am...
2
by: scratchadere | last post by:
I am tryin to partition a listbox into multiple columns.Here is the real problem.I am getting data from MS ACCESS database.I want to display it juz like how an email account displays unread messages...
3
by: MikeB | last post by:
Hello, I have a content page that is from a Master page which has 2 content panes. How do I add my forms to the content page? Each pane needs a form but you can not have multiple form tags nor...
4
by: rn5a | last post by:
A MS-Access DB has 3 tables - Teacher, Class & TeacherClass. The Teacher table has 2 columns - TeacherID & TeacherName (TeacherID being the primary key). The Class table too has 2 columns - ClassID...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.