Link to home
Start Free TrialLog in
Avatar of GarySB
GarySB

asked on

How to update Web Access Database field using VB

I want to have a simple Access Database with my web pages and have a field that gets incremented everytime the program is installed.  Or a new record could be added with the user name and date. I already have a registration routine and know how to make the database as well as upload it, but do not know the instructions to change the value of a Access field or how to specifically reference the field through VB once it is located with web pages. Can you please give me a example using VB Express 2008 and VB 6.0, Thank You
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

You cannot connect to a remote Access database. If you own the webserver, you could possibly create a VPN solution that would do this, but even then this would be an iffy concept. Or, you could build a simple ASP.NET page that could do this for you.

Or, move your data to a server-type database, like MS SQL Server, MySQL etc ... you can connect to remote instances of those engines via an IP address and standard connection string.
Avatar of GarySB
GarySB

ASKER

Alright, so your saying that it could be accomplished using MS SQL Server. My goal is simply to be able to tell how many times the program is being installed.  Do you know of a different way of accompilshing this?  Right now my program references fields in the .html web page and reads them into variables in the program.  So say for instance one variable is equal to 1.  I want to now make it 2 and write it back.  Either I need the ability to write/update the .html web page or write to a MS SQL Server database or since I have all the variables I just read in make a new .html page and upload it using the date as part of the name.  Please give me your opinion, Thank You
Yes, you could do this with SQL Server (or MySQL, or Oracle, or any other database that supports remote connections).

I'm not really sure what your goal is, but there are much better ways of protecting your app (if that's what you're doing) than this:  

http://www.ssware.com/cryptolicensing/cryptolicensing_ocx.htm

Avatar of GarySB

ASKER

Do you have an example of instruction to change a field?  Thank You and I will look into the link you gave, but right now I wish to complete the work I've started.  I'll increase the points to 500 for you.
Avatar of GarySB

ASKER

My goal is to be able to see how many times the program has been installed and by changing a value denying future installaitons.
You simply build a connection to your web-based database, then execute a query:

Dim con As ADODB.connection
Set con = New ADODB.Connection

con.Open "Your connect string"

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM SomeTable", con

If Not (rst.EOF and rst.BOF) Then
  If rst("YourField") = 30 Then
    Msgbox "This has been installed too many times"
    Application.Quit
  End If
End If

Set rst = Nothing
con.Close
Set Con = Nothing
Sorry ... hit submit too quick ...

To build your connection:

con.Open "ODBC;Driver={SQL Native Client};" &
           "Server=MyServerName;" & _
           "Database=myDatabaseName;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"

Obviously you'd have to change MySerName, MyDatabaseName, MyUserName and My Password to match your own

This came from here: http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer

There are also strings for other db engines as well.
Avatar of GarySB

ASKER

Thank You, Last thing (I updated points already)
 If rst("YourField") = 30 Then
is good for testing maximum installations, but what would increment "YourField" each time its installed?  That is what I'm essentially looking for, Thank You
Avatar of GarySB

ASKER

Something like:
 If rst("YourField") = 30 Then
    Msgbox "This has been installed too many times"
    Application.Quit
Else
    rst("YourField") =  rst("YourField") + 1
  End If
How do I update  rst("YourField")?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GarySB

ASKER

Thank You!!!