PC Review


Reply
Thread Tools Rate Thread

QueriesTableAdapter

 
 
peterg12345@gmail.com
Guest
Posts: n/a
 
      2nd Mar 2008
Newbie question:

I have created a custom query using the Query Builder, and it shows up
as a QueriesTableAdapter entry in the .xsd file. Now, how do I make
the results of this query available to a grid object on my form? IOW,
how do I make it a data source?


TIA
 
Reply With Quote
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      3rd Mar 2008
Peter-

Set the XSD file in DataSet mode on your designer(left bellow)
right click and tell to generate a dataset

-Cor
 
Reply With Quote
 
 
 
 
peterg12345@gmail.com
Guest
Posts: n/a
 
      3rd Mar 2008
I don't mean to sound stupid, but could you clarify the steps I need
to take. Right now, I am looking at a dataset.xsd file which has a
QueriesTableAdapter object containing my SQL -- qryIssuesList().

How do I set the xsd file into dataset mode? How do I tell it to
generate a dataset?

TIA,
Pete



On Mar 2, 9:36 pm, "Cor Ligthert[MVP]" <(E-Mail Removed)>
wrote:
> Peter-
>
> Set the XSD file in DataSet mode on your designer(left bellow)
> right click and tell to generate a dataset
>
> -Cor


 
Reply With Quote
 
Rich P
Guest
Posts: n/a
 
      3rd Mar 2008
Using the wizards will restrict your objects considerably. You are
better off doing this in code as follows (I am using Windows
Authentication in this sample if you are using Sql Server):

--------------------------------------------
Imports System
Imports System.Data.SqlClient

Dim conn As SqlConnection, da As SqlDataAdapter
Dim ds As Dataset

Private Sub Form1_Load(...) Handles MyBase.Load
conn1 = New SqlConnection
conn1.ConnectionString = "Data Source=yourSvr;Initial
Catalog=yourDB;Integrated Security=True"

ds = New Dataset
da = New SqlDataAdapter
da.SelectCommand = New SqlCommand
da.SelectCommand.Connection = conn
da.SelectCommand = "Select * From yourTbl"
da.Fill(ds, "tblSteve")

datagridview1.DataSource = ds.Tables("tblSteve")
End Sub
----------------------------------------------

Just create a new form and drop a datagridview control on it. Then copy
and paste the code above into your new form. Replace yourTbl with the
name of an actual table on your server DB. Now load the project and you
will see the data in your form's datagridview control.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
peterg12345
Guest
Posts: n/a
 
      4th Mar 2008
Thanks Rich - that's what I was looking for.

"Rich P" wrote:

> Using the wizards will restrict your objects considerably. You are
> better off doing this in code as follows (I am using Windows
> Authentication in this sample if you are using Sql Server):
>
> --------------------------------------------
> Imports System
> Imports System.Data.SqlClient
>
> Dim conn As SqlConnection, da As SqlDataAdapter
> Dim ds As Dataset
>
> Private Sub Form1_Load(...) Handles MyBase.Load
> conn1 = New SqlConnection
> conn1.ConnectionString = "Data Source=yourSvr;Initial
> Catalog=yourDB;Integrated Security=True"
>
> ds = New Dataset
> da = New SqlDataAdapter
> da.SelectCommand = New SqlCommand
> da.SelectCommand.Connection = conn
> da.SelectCommand = "Select * From yourTbl"
> da.Fill(ds, "tblSteve")
>
> datagridview1.DataSource = ds.Tables("tblSteve")
> End Sub
> ----------------------------------------------
>
> Just create a new form and drop a datagridview control on it. Then copy
> and paste the code above into your new form. Replace yourTbl with the
> name of an actual table on your server DB. Now load the project and you
> will see the data in your form's datagridview control.
>
> Rich
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      4th Mar 2008
Rich,

This is a complete different result then using the designer.

Be aware that you are now using a non strongly typed dataset, which is in
fact complete different (less stable) then a strongly typed dataset created
using an XSD file.

Cor

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      4th Mar 2008
Pete-

I don't mean to sound stupid, but could you clarify the result you want to
get.
Right now, I am looking at a solution for a non strongly typed dataset which
does not have a
QueriesTableAdapter object containing your SQL -- qryIssuesList().

What has this to do with a xsd file into?

TIA,
Cor


"peterg12345" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Thanks Rich - that's what I was looking for.
>
> "Rich P" wrote:
>
>> Using the wizards will restrict your objects considerably. You are
>> better off doing this in code as follows (I am using Windows
>> Authentication in this sample if you are using Sql Server):
>>
>> --------------------------------------------
>> Imports System
>> Imports System.Data.SqlClient
>>
>> Dim conn As SqlConnection, da As SqlDataAdapter
>> Dim ds As Dataset
>>
>> Private Sub Form1_Load(...) Handles MyBase.Load
>> conn1 = New SqlConnection
>> conn1.ConnectionString = "Data Source=yourSvr;Initial
>> Catalog=yourDB;Integrated Security=True"
>>
>> ds = New Dataset
>> da = New SqlDataAdapter
>> da.SelectCommand = New SqlCommand
>> da.SelectCommand.Connection = conn
>> da.SelectCommand = "Select * From yourTbl"
>> da.Fill(ds, "tblSteve")
>>
>> datagridview1.DataSource = ds.Tables("tblSteve")
>> End Sub
>> ----------------------------------------------
>>
>> Just create a new form and drop a datagridview control on it. Then copy
>> and paste the code above into your new form. Replace yourTbl with the
>> name of an actual table on your server DB. Now load the project and you
>> will see the data in your form's datagridview control.
>>
>> Rich
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
QueriesTableAdapter connection string reset Roger Microsoft Dot NET Framework Forms 0 5th Sep 2008 12:34 PM
QueriesTableAdapter does not appear in toolbox. Why not? HONOREDANCESTOR@YAHOO.COM Microsoft ADO .NET 1 18th Oct 2007 12:29 AM
ConnectionString in QueriesTableAdapter =?Utf-8?B?SmFu?= Microsoft ADO .NET 3 12th Jul 2006 09:16 AM
Modifier for QueriesTableAdapter =?Utf-8?B?RGljaw==?= Microsoft ADO .NET 5 19th Jan 2006 04:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 AM.