connelvalentine
asked on
Best methods for accessing and manipulating database from VB.NET
Hi,
I'm new to programming in VB.NET and SQL. i'd like to ask a general question regarding accessing a database from a VB.NET application.
What would be the most efficient method for manipulating the database from the application? I've read that using stored procedures are the best way to do this. Do i use stored procedures for every and all ways to manipulate the db - adding, delting, modifying, querying etc.?
Is using datasets also the best way of connecting your application to the database?
Appreciate any advice you could give me on this. Thanks.
BR,
CV.
I'm new to programming in VB.NET and SQL. i'd like to ask a general question regarding accessing a database from a VB.NET application.
What would be the most efficient method for manipulating the database from the application? I've read that using stored procedures are the best way to do this. Do i use stored procedures for every and all ways to manipulate the db - adding, delting, modifying, querying etc.?
Is using datasets also the best way of connecting your application to the database?
Appreciate any advice you could give me on this. Thanks.
BR,
CV.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>Parentgrd.DataSource = ds.Tables("Parent")<<
MS insists on using BindingSource under VS 2005 to synchronize cursor
MS insists on using BindingSource under VS 2005 to synchronize cursor
Ark
>>
MS insists on using BindingSource under VS 2005 to synchronize cursor
<<
Just where, and how, does MS INSIST on that? VS 2005 offers, for the first time, a BindingSource. But that MS INSISTS on its use is news to me.
Roger
>>
MS insists on using BindingSource under VS 2005 to synchronize cursor
<<
Just where, and how, does MS INSIST on that? VS 2005 offers, for the first time, a BindingSource. But that MS INSISTS on its use is news to me.
Roger
Hi Roger
http://msdn2.microsoft.com/en-us/library/fbk67b6z(VS.80).aspx
<QUOTE>The DataGridView control supports the standard Windows Forms data binding model, so it will bind to a variety of data sources. In most circumstances, however, you will bind to a BindingSource component which will manage the details of interacting with the data source. The BindingSource component can represent any Windows Forms data source and gives you great flexibility when choosing or modifying the location of your data.</QUOTE>
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx
<QUOTE>The BindingSource component is the preferred data source because it can bind to a wide variety of data sources and can resolve many data binding issues automatically.</QUOTE>
Also you can check MS samples on databindings - most of them use BindingSource. MS doesn't say "you should use BindingSources in all cases" but it says it's <<the preferred data source>>
Regards
Ark
http://msdn2.microsoft.com/en-us/library/fbk67b6z(VS.80).aspx
<QUOTE>The DataGridView control supports the standard Windows Forms data binding model, so it will bind to a variety of data sources. In most circumstances, however, you will bind to a BindingSource component which will manage the details of interacting with the data source. The BindingSource component can represent any Windows Forms data source and gives you great flexibility when choosing or modifying the location of your data.</QUOTE>
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx
<QUOTE>The BindingSource component is the preferred data source because it can bind to a wide variety of data sources and can resolve many data binding issues automatically.</QUOTE>
Also you can check MS samples on databindings - most of them use BindingSource. MS doesn't say "you should use BindingSources in all cases" but it says it's <<the preferred data source>>
Regards
Ark
Ark
I know the docs say that. And they also say
>>
The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:
The IList interface, including one-dimensional arrays.
The IListSource interface, such as the DataTable and DataSet classes.
The IBindingList interface, such as the BindingList class.
The IBindingListView interface, such as the BindingSource class.
<<
To me, that doesn't look quite the same as "insists" ;-)
I wouldn't have quibbled if you'd said there were other methods, or even that other methods might be better. But ...
Roger
I know the docs say that. And they also say
>>
The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:
The IList interface, including one-dimensional arrays.
The IListSource interface, such as the DataTable and DataSet classes.
The IBindingList interface, such as the BindingList class.
The IBindingListView interface, such as the BindingSource class.
<<
To me, that doesn't look quite the same as "insists" ;-)
I wouldn't have quibbled if you'd said there were other methods, or even that other methods might be better. But ...
Roger
Sorry, seems this is due to my poor English :)
OK, let it be nt "insists" but "strongly recommended" :)
OK, let it be nt "insists" but "strongly recommended" :)
Fine ;-)
Well that really depends on one's temper and approach to things.
If it is a company solution that requere's you use SP or you are workinking with heavy loads of data then
SP would be the way to go, due to performance that you'll gain that the server provide.
Another approach is to control things you self by writing the specific requerements your self.
Imports System.Data
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim daParent As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "PROVIDER=Microsoft.Jet.OL
sql = "SELECT * FROM Parent"
con.Open()
daParent = New OleDb.OleDbDataAdapter(sql
daParent.Fill(ds, "Parent")
con.Close()
Parentgrd.DataSource = ds.Tables("Parent")
End Sub
'update all change's made in the datagridview
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cb As New OleDb.OleDbCommandBuilder(
daParent.Update(ds, "Parent")
MsgBox("Data updated")
End Sub
End Class
vbturbo