Taha Khan
Taha Khan

Reputation: 43

How to you alias in dataadapter query?

I am using a sql server database and i am storing the time value in the datetime variable. I am developing a booking system application in vb.net. When I want to view already made bookings using datagridview and by implementing dataadapter and dataset...When the table is shown in the datagridview I want custom column names to be shown so can any one tell me that how can i use alias in the query given in datadapter initialization part

Upvotes: 1

Views: 395

Answers (1)

Chains
Chains

Reputation: 13157

In the query...

Select
   field1 as [First Name],
   field2 as [Last Name],
   ...
From
   table

In the code-behind:

dataGridView1.Columns(0).Name = "First Name"
dataGridView1.Columns(1).Name = "Last Name"

In the designer:

DataPropertyName 

Upvotes: 1

Related Questions