container for tables & queries in VB.NET 2008

  • Thread starter Thread starter Mr. X.
  • Start date Start date
M

Mr. X.

Hello.
Is there any container on VB.NET 2008, so I can drop queries & tables
objects on it?

Thanks :)
 
Try a Dataset. You can select it from the Add menu under "Dataset"
(.xsd file) or create it in code

Dim ds As New Dataset

Rich
 
Can I drop mySqlConnection or other connection objects to such a container,
or similar ?

Thanks :)
 
I you select a Dataset (.xsd) from the Add menu, then in the Server
Explorer (View menu) you can connect to whichever database and drag a
table or tables into the Dataset window. I think another option to
right-click in the Dataset window and select Add TableDataAdapter which
will bring up a wizard that you can click through.

Rich
 
What I see is only few components I can drop on dataset.
TableAdapter, Query, DataTable, Relation.
I didn't see a way dropping connection.
(The specified connection is : mySqlConnection).

I want to drop the connection on design time.
Can I see more elements than the above four.

Thanks :)
 
Am 31.03.2010 10:54, schrieb Mr. X.:
What I see is only few components I can drop on dataset.
TableAdapter, Query, DataTable, Relation.
I didn't see a way dropping connection.
(The specified connection is : mySqlConnection).

I want to drop the connection on design time.
Can I see more elements than the above four.

You could drop several things on a Form - but what are you trying to do?
 
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).

Thanks :)
 
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
 
(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 :)
 
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 :)
 
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. said:
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 :)
 
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 :)
 
Back
Top