-
Feb 5th, 2015, 06:35 AM
#1
Thread Starter
Addicted Member
OleDbCommand , OleDbDataAdapter
friends
this code work with me very very good
but some thing i can't understand
why i use OleDbDataAdapter in this code
this code can work without OleDbDataAdapter
why in this code
OleDbDataAdapter
is added
Code:
Try
cn.Open()
Dim da As New OleDbDataAdapter
Dim com As New OleDbCommand
com.Connection = cn
com.CommandText = "insert into tblclient (ClientName)values('zzzzzzzzzzzzzzzzzzzzzz')"
da.InsertCommand = com
da.InsertCommand.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
-
Feb 5th, 2015, 06:39 AM
#2
Re: OleDbCommand , OleDbDataAdapter
You shouldn't be using a data adapter in that situation. It's pointless. A data adapter is a way to combine four commands that can be used to retrieve data from a database into a DataTable and then save changes from that DataTable back to the database. You call Fill to execute the SelectCommand and then you call Update to execute InsertCommand, UpdateCommand and DeleteCommand.
-
Feb 5th, 2015, 07:38 AM
#3
Thread Starter
Addicted Member
Re: OleDbCommand , OleDbDataAdapter
Originally Posted by jmcilhinney
You shouldn't be using a data adapter in that situation. It's pointless. A data adapter is a way to combine four commands that can be used to retrieve data from a database into a DataTable and then save changes from that DataTable back to the database. You call Fill to execute the SelectCommand and then you call Update to execute InsertCommand, UpdateCommand and DeleteCommand.
thank you for your answer;
[]
Dim da As New OleDbDataAdapter("select * from tblclient", cn)
Dim dt As New DataTable
da.Fill(dt)
[/code]
i fill data table with OleDbDataAdapter
how can i delete clientid =1
how can i edit clientid =5
how can i insert another client
thank you very much for you advice and help and time;
-
Feb 5th, 2015, 04:50 PM
#4
Re: OleDbCommand , OleDbDataAdapter
Instead of asking questions on every little thing here, I would suggest that you read a tutorial or two. The VB beginners tutorial link in my signature below includes some information on data access. You might also follow the Database FAQ link and check out some of the .NET resources there.
-
Feb 5th, 2015, 06:59 PM
#5
Thread Starter
Addicted Member
Re: OleDbCommand , OleDbDataAdapter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|