[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Putting data into access database from visual basic program

Posted on 2006-11-08
6
Medium Priority
?
224 Views
Last Modified: 2010-04-16
What I have is a program for checking leaks. The user inputs the pressures and temps and calcs the difference and displays this to the user. What I want to do is on the form the users fills in serial number and a couple other fields including pressures and temperatures and then pushes the calc button. When the button is pushed it calcs the difference and inputs all the information into a database.

Is this possible?
0
Comment
Question by:Kirius
[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 Comments
 
LVL 2

Expert Comment

by:jay_s5
ID: 17901931
Yes, it is definitely possible. The easy part--once you know how to do it--is building the program.

What you are describing is using an Access backend for a Visual Basic application. An alternative would be to use VB code in Access to build an Access application to do the same thing.

The hard part is packaging the program and installing it on a user's machine because you will be dealing with issues regarding Microsoft's Data Access Components (MDAC) that are absent on some Windows 98 and earlier machines, and present, but with differing versions on Windows XP machines. The Packaging and Deployment Wizard in VB is not very helpful when it comes to the installation of the MDAC, so you have to resort to C++ scripts with Windows Studio Installer or another installation tool. If you know you will only be dealing with Windows XP machines, you may get away without hassling with an MDAC update/installation.

As an alternative to the VB/Access route, which would involve installing a program on all the users' machines, I would suggest using PHP and MySQL via a website to run your program. That way, it will work on Windows and Mac, there won't be any software to install, and your users can access the program from any internet-capable device.
0
 

Expert Comment

by:shwaqar82
ID: 17903631
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.OleDb" %>  


That means we will use VB as the default coding language and we are going to use OLEDB .NET data provider. Now, here's the code for doing simple query using ADO.NET

<script language="vb" runat="server">

Sub Page_Load(sender as Object, e as EventArgs)
  'Get the Database Path, to be used in DB Connection String
  Dim sDBPath As String = Request.MapPath(".") & "\NWind.mdb"

  'Define DB Connection String
  Dim sCnnString As String = "Provider=Microsoft.Jet.Oledb.4.0;" & _
                             "Data Source=" & sDBPath

  'Define variables as input for our sql query
  Dim temperature As String  = txtTemp.Text.ToString
  Dim difference As String = txtDifference.Text.ToString
  Dim pressure As String = txtPressure.Text.ToString

  'Populate Connection Object
  Dim oCnn As New OleDbConnection(sCnnString)

  'Define our sql query
  Dim sSQL As String = "insert into tablename
(differene, pressure, temperature)
values ('Argos', 'Indiana', '89', '46501');"

  'Populate Command Object
  Dim oCmd As New OledbCommand(sSQL, oCnn)

Try

'Opening Connection for our DB operation  
oCnn.Open()

'Execute the query
oCmd.ExecuteNonQuery()

  Finally

    'Closing the data reader & connection object
    drEmployee.Close()
    oCnn.Close()
   
  End Try
End Sub
</script>

 i dunno what kind od code and fileds ur using

0
 
LVL 1

Author Comment

by:Kirius
ID: 17908608
Well actually what I have is a form with the text boxes of SerialNumber Retest EmpNumber StartPSi EndPSI StartTemp EndTemp LeakLocation, once these are filled it it does a calculation to see whether or not there is a leak. Once this is done I want this information placed into an access database. Maybe this helps a little more. Just 1 table corresponding to those txt boxes and a label named Time.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
tobydavid earned 500 total points
ID: 17914269
This would be the general routine for the calc button:


Private Sub CalcBtn_Click()
Dim db As Database
Dim tb As TableDef
Dim rs As Recordset
‘*** Perform Calulation ***
‘ ….
‘*** Update Data Table ***
Set db = OpenDatabase("D:\...\....mdb")  ' Your dataset path an name
Set tb = db.TableDefs("YourTableName")
Set rs = tb.OpenRecordset
On Error Resume Next
rs.MoveLast
rs.AddNew
rs.Fields("FieldName1") = Value1
rs.Fields("FieldName2") = Value2
rs.Fields("FieldName3") = Value3
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
db.Close

End Sub
0
 
LVL 1

Author Comment

by:Kirius
ID: 17914661
tobydavid Worked perfectly was exactly what I was looking for.
0
 
LVL 4

Expert Comment

by:tobydavid
ID: 17914682
Great.  Glad to have helped.

TB
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

656 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