From: Mr. X. on
When I put on the dataset a query - It should be referred to a connection,
and it is build with a wizard.
But what if I want to refer to an existing connection object (the connection
is known before using the query on the dataset), or know what is behind the
query and resolve the connection object from it ?

Thanks :)

"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:#xBgwmQ0KHA.3708(a)TK2MSFTNGP02.phx.gbl...
> (Now I see that your email is nospam too). :)
>
> I see that on windows-form I can drop mySqlConnection object (under
> toolbox -> dataset -> mySqlConnection).
> Other objects are not seen on toolbox -> dataset, when windows-form is
> active.
> On dataset - the other objects I have mentioned are visible (except
> mySqlConnection).
>
> It is no obvious, since I want a visual tool that is dedicated to
> databases.
>
> Is there any other visual tool I can drop mySqlConnection.
> If not - where it is preferred to be dropped to.
>
> Thanks :)
>
> "Armin Zingler" <az.nospam(a)freenet.de> wrote in message
> news:uyFNbMP0KHA.348(a)TK2MSFTNGP02.phx.gbl...
>> Am 31.03.2010 18:21, schrieb Mr. X.:
>>> I want to drop elements on a dataset.
>>> As far as I remember, Delphi IDE, i.e , has dataset, which I can drop
>>> also a
>>> connections on it.
>>> I don't understand why connections and other elements cannot be dropped
>>> to
>>> dataset
>>> (Or should I declare the connection somehow on the toolbox).
>>
>> Connections are not part of a DataSet. A Dataset is a container for
>> DataTables (containing datarows) and DataRelations.
>>
>> Documentation on Datasets:
>> http://msdn.microsoft.com/en-us/library/ss7fbaez.aspx
>>
>> --
>> Armin
>
From: Cor Ligthert[MVP] on
If you start for the first time there is no existing connection.

The second time you can select them from the dropdown which is placed left.


"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:#NcFbNR0KHA.5344(a)TK2MSFTNGP02.phx.gbl...
> When I put on the dataset a query - It should be referred to a connection,
> and it is build with a wizard.
> But what if I want to refer to an existing connection object (the
> connection is known before using the query on the dataset), or know what
> is behind the query and resolve the connection object from it ?
>
> Thanks :)
>
> "Mr. X." <nospam(a)nospam_please.com> wrote in message
> news:#xBgwmQ0KHA.3708(a)TK2MSFTNGP02.phx.gbl...
>> (Now I see that your email is nospam too). :)
>>
>> I see that on windows-form I can drop mySqlConnection object (under
>> toolbox -> dataset -> mySqlConnection).
>> Other objects are not seen on toolbox -> dataset, when windows-form is
>> active.
>> On dataset - the other objects I have mentioned are visible (except
>> mySqlConnection).
>>
>> It is no obvious, since I want a visual tool that is dedicated to
>> databases.
>>
>> Is there any other visual tool I can drop mySqlConnection.
>> If not - where it is preferred to be dropped to.
>>
>> Thanks :)
>>
>> "Armin Zingler" <az.nospam(a)freenet.de> wrote in message
>> news:uyFNbMP0KHA.348(a)TK2MSFTNGP02.phx.gbl...
>>> Am 31.03.2010 18:21, schrieb Mr. X.:
>>>> I want to drop elements on a dataset.
>>>> As far as I remember, Delphi IDE, i.e , has dataset, which I can drop
>>>> also a
>>>> connections on it.
>>>> I don't understand why connections and other elements cannot be dropped
>>>> to
>>>> dataset
>>>> (Or should I declare the connection somehow on the toolbox).
>>>
>>> Connections are not part of a DataSet. A Dataset is a container for
>>> DataTables (containing datarows) and DataRelations.
>>>
>>> Documentation on Datasets:
>>> http://msdn.microsoft.com/en-us/library/ss7fbaez.aspx
>>>
>>> --
>>> Armin
>>
From: Mr. X. on
I have solved the problem, by doing some code, and not using/ the IDE.
IDE was good for fast table creation (on dataset).
(For some things, it was better using some code behind).

The following example (by datagridview.datasouce) was just fine, and I have
learned by it using dataadapter
(Also good for insert, update, delete).
It binds on runtime, and not on the design time the connection.


Public Class Form1
Inherits System.Windows.Forms.Form

Private WithEvents dataGridView1 As New DataGridView()
Private bindingSource1 As New BindingSource()

Public Sub New()

Me.dataGridView1.Dock = DockStyle.Fill
Me.Controls.Add(Me.dataGridView1)
InitializeDataGridView()

End Sub

Private Sub InitializeDataGridView()
Try
' Set up the DataGridView.
With Me.dataGridView1
' Automatically generate the DataGridView columns.
.AutoGenerateColumns = True

' Set up the data source.
bindingSource1.DataSource = GetData("Select * From
Products")
.DataSource = bindingSource1

' Automatically resize the visible rows.
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders

' Set the DataGridView control's border.
.BorderStyle = BorderStyle.Fixed3D

' Put the cells in edit mode when user enters them.
.EditMode = DataGridViewEditMode.EditOnEnter
End With
Catch ex As SqlException
MessageBox.Show("To run this sample replace " _
& "connection.ConnectionString with a valid connection
string" _
& " to a Northwind database accessible to your system.", _
"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
System.Threading.Thread.CurrentThread.Abort()
End Try
End Sub

Private Shared Function GetData(ByVal sqlCommand As String) _
As DataTable

Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False;" _
& "Initial Catalog=Northwind;Data Source=localhost"

Dim northwindConnection As SqlConnection = _
New SqlConnection(connectionString)

Dim command As New SqlCommand(sqlCommand, northwindConnection)
Dim adapter As SqlDataAdapter = New SqlDataAdapter()
adapter.SelectCommand = command

Dim table As New DataTable
table.Locale = System.Globalization.CultureInfo.InvariantCulture
adapter.Fill(table)

Return table

End Function

<STAThreadAttribute()> _
Public Shared Sub Main()
Application.Run(New Form1)
End Sub

End Class

....


Thanks :)