?
Solved

How to update Web Access Database field using VB

Posted on 2009-07-06
11
Medium Priority
?
181 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:GarySB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 85
ID: 24803059
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.
0
 

Author Comment

by:GarySB
ID: 24813258
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
0
 
LVL 85
ID: 24814177
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

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:GarySB
ID: 24860761
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.
0
 

Author Comment

by:GarySB
ID: 24861292
My goal is to be able to see how many times the program has been installed and by changing a value denying future installaitons.
0
 
LVL 85
ID: 24861605
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
0
 
LVL 85
ID: 24861631
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.
0
 

Author Comment

by:GarySB
ID: 24862131
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
0
 

Author Comment

by:GarySB
ID: 24862322
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")?
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 24864018
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, adOpenKeySet, adLockOptimistic

If Not (rst.EOF and rst.BOF) Then
  If rst("YourField") = 30 Then
    Msgbox "This has been installed too many times"
    Application.Quit
  Else
    rst("YourField") = rst("YourField") + 1
    rst.Update
  End If
Else
  '/WHAT ABOUT IF THE APP CANNOT CONNECT
End If

Set rst = Nothing
con.Close
Set Con = Nothing
0
 

Author Closing Comment

by:GarySB
ID: 31600124
Thank You!!!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question