INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...Since using forums in my early days 10 years ago in CompuServe, one had to log back on and sometimes wait days for a response. Now I get a response e-mailed to me which I can click a link and go right back to exactly where My post was..."
Where in the world do Tek-Tips members come from?
Update a Non Indexed table using OleDbDataAdapter
Posted: 12 Sep 02 (Edited 16 Jan 03)
I struggled for some time, trying to understand the procedure to update via an OleDbDataAdapter. This is what I learned and I hope it helps you.
First we make our declarations of what we will need. We also declare our SELECT query that will start us off.
Dim strSql As String = "SELECT * FROM tblNewOrderNum"
Dim objData AS New DataSet()
Dim objConn As New OledbConnection(Application("dbAccess"))
Dim objAdapt As New OleDbDataAdapter(strSql, objConn)
Dim objTable As DataTable
Dim objRow As DataRow
Dim strNewNumI, strNewNum As String
objAdapt.Fill(objData, "NewOrders") ' This is where we fill our DataSet so that we can use it.
Work with your dataset here.
'First we want to create our UPDATE command.
'The question mark specifies that we will later put a parameter (a variable of sorts) here. This will not work unless we add the parameter!
objAdapt.UpdateCommand = new oledbcommand("UPDATE tblNewOrderNum SET wOrders = ? ", objConn)
'Here we are going to do a number of things.
'First we tell .Net that we want to Add a Parameter to the Updatecommand for objAdapt.
'But of course we specify what that paramerter is with "@myParam". The @ is imperative as it specifies that this is our parameter name.
'Then we specify the type. You can find a listing of types here:
'The size is also specified. For DataTypes like Int we do not need this.
'We also specify the Value here. We could do this later, but I do it now. Note: The dataType for this Value must corespond with the dataType of the parameter.
objAdapt.Updatecommand.Parameters.Add("@myParam", system.data.oledb.OleDbType.VarWChar, 15).Value = someValue
'This specifies the column we are updating. We may be able to drop this since we have specified it in the Query string, but I don't know for sure yet, so I leave it in.
'Then of couse, run our update, specifying which dataset and dataTable in that DataSet we will be updating..
Catch ex As Exception
Msg.Text = ex.ToString ' We won't need this since we are such excellent programmers, but just in case.
So that's it. I hope I have helped some of you up there understand this better. Check that link out. It has more information on this but is a little complex, at least it was for me. K, there you go. ;)
Back to Microsoft: ASP.NET FAQ Index
Back to Microsoft: ASP.NET Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close