|
-
Dec 25th, 2002, 09:05 PM
#1
Thread Starter
Member
take specific column from dataset
Hi All,
I am selecting all records to dataset from my table.After that i need to select specific column from dataset and to display in datagrid.
How will i do that?
My table has Id,Firstname,LastName,Address,Phone,City,State,Fax and Zip
I want to selelct FirstName,lastname and address from my dataset and display in datagrid.
My code is :
Private Sub ButReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButReport.Click
Dim SQLConn As SqlConnection
SQLConn = New SqlConnection()
Dim sConnectionString As String
sConnectionString = "Data Source=Lidya;user id=sa;PWD=;Initial Catalog=pubs;"
SQLConn = New SqlConnection(sConnectionString)
Dim SQLCommand As New SqlCommand("SELECT * FROM addressdb", SQLConn)
Dim SQlAdop As New SqlDataAdapter(SQLCommand)
Dim mydataset As New DataSet("selectAddress")
Try
SQLConn.Open()
SQlAdop.Fill(mydataset, "addressdb")
' Dim rowaddress As System.Data.DataRow
DataGrid1.DataSource = mydataset
Catch Mycxception As Exception
MessageBox.Show(Mycxception.ToString())
Finally
If SQLConn.State = ConnectionState.Open Then
SQLConn.Close()
End If
If Not mydataset Is Nothing Then
mydataset = Nothing
End If
End Try
End Sub
Please help me out.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|