Access and VB.Net?

Shane80

Member
Joined
Jun 16, 2004
Messages
5
Programming Experience
Beginner
Hello

I am new to VB so go easy on me. I have created a VB forum and I have also created an Access Data Base and have successful link the two, but my question is how do I add new records to the Access database using the VB forum? I have created a Save/add button but that is as far as I have got. I would like to be able to add the record in the VB forum and then have it save it to the Access database and also make it so that I can view the updated record in the VB forum.



Thanks for any help
 

lOnEr

Member
Joined
Jun 18, 2004
Messages
14
Programming Experience
Beginner
actually i cant understand what is your trying to figure out..

just make a command text.
and now you can add a records in your database. i dont know about access database..

what i know is just mssql 2000..
what im doing is i'll make a stored procedure to add some records in my database..
 
Last edited:

Shane80

Member
Joined
Jun 16, 2004
Messages
5
Programming Experience
Beginner
Thats cool thanks anyways.

I guess maybe I am doing something wrong when I write the line of code that saves the file to the Access database.
 

Shane80

Member
Joined
Jun 16, 2004
Messages
5
Programming Experience
Beginner
I think I found my problem, But I need to know how to change my ConnectionString I need to make it Microsoft Jet 4.0 OLE DB Provider.
 

lOnEr

Member
Joined
Jun 18, 2004
Messages
14
Programming Experience
Beginner
Shane80 said:
I think I found my problem, But I need to know how to change my ConnectionString I need to make it Microsoft Jet 4.0 OLE DB Provider.
im sorry i cant help w/ your problem..
try to google it..

dig for your self..
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
As with all things .NET, there are many ways to accomplish this.

First, when you say VB forum, I assume you mean form?
How are you linking the form and the database?
Are you using Visual Studio?

This thread show how to use SQL statement, OleDbAdapters, and OleDbCommand with parameters to update a record in an Access database: Updating a MS Access table row

If this isn't what you're looking for, I'll wait for you to answer the above questions before elaborating further.
 

Shane80

Member
Joined
Jun 16, 2004
Messages
5
Programming Experience
Beginner
Thanks Paszt :) I think this will help me with my problem a great deal.

Thanks
 

Shane80

Member
Joined
Jun 16, 2004
Messages
5
Programming Experience
Beginner
Sorry but I do have a quick question. I am getting the "not declared" error even after I name it the name I have used for my OleDbDataAdapter()

Code:
Dim upd_sql As String = "UPDATE mem_tran set amount=[@amnt] " & _
"WHERE customer=[@cst] and service=[@sv]"
Dim da As New OleDbDataAdapter()
Dim da As New DbMoneyOrder
Dim ds As New DataSet()
Dim x As Integer
Dim cu As OleDbCommand = New OleDbCommand(upd_sql, oleDbConnection1)
Dim cu As DbMoneyOrder1 = New OleDbCommand(upd_spl, oleDbConnection1)
'don't need the next statement, it's set above
'da.UpdateCommand = cu
cu.Parameters.Add("@amnt", OleDbType.Double).Value = 110.0
^What is OleDbType.Double?
cu.Parameters.Add("@cst", OleDbType.WChar, 8).Value = "ADEN"
^What is OleDbType.WChar?
cu.Parameters.Add("@sv", OleDbType.Integer).Value = 40500000
^What is OldDbType.Integer
Try
oleDbConnection1.Open()
x = cu.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
'put close in try/catch block in case
'the connection wasn't opened
Try
oleDbConnection1.Close()
Catch : End Try


Sorry If I am not getting my point across.
I am a little lost on some of that code.:(
If anyone knows of a good book on this subject then let me know

Note the stuff in read is were I need help.
 
Last edited:

gahlyan

New member
Joined
May 6, 2007
Messages
2
Programming Experience
Beginner
Hi,
Im using MS Access as database,
But totally confused creating Dataset.
When i click on "Generate Dataset" a window got opened, and demand some username ande password, which i dnt have,
If i cancel that then did nt show any table.
Can i Create Dataset using coding only.
Not this cofusing process.
Dim ds As New Dataset is enough for creating dataset?

Thanks in advance and looking forward for your reply.
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
The Dataset wizard will help you create a typed dataset which, depending on your app, may simplify things.
In the wizard, if the database isn't password protected just leave the username/password blank and click OK instead of cancel.

Yes, of course you can create a dataset in code. Actually that is the only way to create a dataset; the wizard simply writes the code for you.
 

gahlyan

New member
Joined
May 6, 2007
Messages
2
Programming Experience
Beginner
Thanks for your reply.
But will help me in code.

Dim ds As new Dataset

fill.dataset(table)
Is this enough.

And when i connect through this shows problem of MDAC compatibility.
In my system it find out MDAC2.9 and send message that there is need of 2.6 or latter.But did not coonect.

If i create dataset through coding do im going to encounter with this problem?
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
Read the DW2 link in my signature, starting with "Creating a simple application"
 
Top Bottom