.NET Framework - QueriesTableAdapter
Asked By peterg1234
02-Mar-08 10:27 PM
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
System.Data.SqlClient
(1)
SqlDataAdapter
(1)
SqlConnection
(1)
SqlCommand
(1)
Tables
(1)
QueriesTableAdapter
(1)
Replace
(1)
Load
(1)
Cor Ligthert[MVP] replied...
Peter-
Set the XSD file in DataSet mode on your designer(left bellow)
right click and tell to generate a dataset
-Cor
peterg1234 replied...
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]" <notmyfirstn...@planet.nl>
Rich P replied...

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 ***
peterg1234 replied...
Thanks Rich - that is what I was looking for.
Cor Ligthert[MVP] replied...
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
Cor Ligthert[MVP] replied...
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
using PS and Sql2005 Backups Maint Thanks. Powershell Discussions Microsoft.SqlServer.Management.Smo.Server (1) System.Data.SqlClient.SqlDataAdapter (1) System.Data.SqlClient.SqlCommand (1) SQL Server 2005 (1) Microsoft.SqlServer.ConnectionInfo (1) System.Data.DataTable (1) System get-date))} if ($cmd.Count -ne $null -and $cmd.Count -ne 0) { $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter $SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlCmd = New-Object System.Data
my code below - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - sub page_load(sender as Object, e as EventArgs) Dim sqlcon As New System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("CONNECTION_STRING")) Dim cmdCat As System.Data.SqlClient.SqlCommand cmdCat.CommandTimeout = 300 Dim daCat As System.Data.SqlClient.SqlDataAdapter Dim dsCat1 As New System.Data.DataSet Dim strCat as String = "SELECT
System.Data.DataSet GetGameDataByGameId() { string connectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString); string queryString = "SELECT * FROM [MyDatabase]"; System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand(); dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection; System.Data.IDbDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter(); dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = new System.Data.DataSet(); dataAdapter
pero no se como resolver el problema, este es el codigo: Dim ConSQL As New System.Data.SqlClient.SqlConnection Dim transaccion As System.Data.SqlClient.SqlTransaction Try ConSQL = New System.Data.SqlClient.SqlConnection(CadenaConexionSQL) ConSQL.Open() transaccion = ConSQL.BeginTransaction While cont < _dst_tmp.Tables("CONTENIDO").Rows
sql connection' es ambiguo en el espacio de nombres system.data.sqlclient .NET Framework Hola, estoy iniciando en vb.net y cuando escribo la conexion a la lo siguiente : Public Function LeoDB(ByVal myQuery As String) As Data.DataSet Dim conn As System.Data.SqlClient.SqlConnection conn = New System.Data.SqlClient.SqlConnection conn.ConnectionString = "Server = MiServer; DataBase = MiBase; user id = user; password = 'pass'" conn