Because I don't ever see a so much simple and powerfull data management as in msaccess, I want to make it simple to vb.net too. All without the wizards that come with visual basic 2005 since I'm using sharpdevelop vb.net.
I'm meaning the easy way of putting a simple sql in the datasource of form/report, and it binds all automatic. I'm trying to do a tool that makes this possible, but I don't know how to make the designs-time.
Here is the code, I'll thank some help.
To bind to a datagridview for example just use:
I'm now trying to make possible a textbox to recognize a databind at design-time, but I don't know how, maybe turning this a class or something?
I'm meaning the easy way of putting a simple sql in the datasource of form/report, and it binds all automatic. I'm trying to do a tool that makes this possible, but I don't know how to make the designs-time.
Here is the code, I'll thank some help.
PHP:
Option Strict Off
Option Explicit Off
imports System.Data
Imports System.Data.OleDb
Public Module dSource
Dim daManual(100)
Dim dsManual =New DataSet
Dim numt=0
Public Sub dtsource(dest as object ,con as String ,strSQL as String )
Try
dim dcManual As New OleDb.OleDbConnection(con)
numt+=1
daManual(numt) = New OleDb.OleDbDataAdapter
daManual(numt).SelectCommand = New OleDb.OleDbCommand(strSQL, dcManual)
dim cbManual= New OleDb.OleDbCommandBuilder(daManual(numt))
daManual(numt).Fill(dsManual, cstr(numt))
dest.DataSource = dsManual.Tables(CStr(numt))
'Im sure there is better way for autoupdate the db,other objects must be added here
If dest.GetType().ToString ="System.Windows.Forms.DataGridView" Then
AddHandler CType(dest,DataGridView).Validated, AddressOf dtValida
End If
If dest.GetType().ToString ="System.Windows.Forms.BindingSource" Then
AddHandler CType(dest,BindingSource).CurrentChanged, AddressOf dtValida
End If
Catch ex As Exception
End Try
End Sub
Public Sub savedataset()
on error resume next
Dim i
If (dsManual.HasChanges) Then
For i = 1 To numt
daManual(i).Update(dsManual.Tables(CStr(i)))
Next i
dsManual.AcceptChanges()
end if
End Sub
Sub dtValida (ByVal sender As System.Object, e As System.EventArgs)
saveDataset
End Sub
End Module
To bind to a datagridview for example just use:
PHP:
dtsource(dataGridView1,"Provider=Microsoft.Jet.OleDb.4.0;Data Source=sample.mdb;","select * from table")
I'm now trying to make possible a textbox to recognize a databind at design-time, but I don't know how, maybe turning this a class or something?