473,786 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linking to Access in VB

I have a project that I am working on that will (ultimately) write to 2 Excel Spreadsheets, 3 Access databases, and communicates with 3 other programs (torque monitoring software, a laser rangefinder, and a specialized industrial inkjet printer). I had much of it working in VB6, but then upgraded (for reasons that I can no longer remember) to .NET. I am now having problems communicating to Access. The main form has 35 text boxes on it fo an operator interface, and using a series of datagrids for the interface is not an option, as this would truely confuse the end users

It seems that most of the material in MSDN assumes that you are using SQL server. Very little is written for Access. This has made life miserable for the last 2 weeks. I should also mention that I am primarily a Network Administrator, but have done some VB programming on the side

I have tried the following
Updating the database from a datasest object (Q301248). (This is where I am at, at present) When the program is run, no errors are found, data column references are accepted, but the database is not updated. Section of code folllows

(in Declarations
Dim drCurrent As DataRo

Dim tblQAData As DataTabl

(during Form load)
tblQAData = PipeData1.Table s("QAData"

(process for writing to 1 database
' Write QA Data for pipe to databas
drCurrent = tblQAData.NewRo
drCurrent("ID") = "
drCurrent("Work Order") = Text3.Tex
If Text25.Text <> "" The
drCurrent("Tube #") = Text25.Tex
End I
If Text5.Text <> "" The
drCurrent("Heat #") = Text5.Tex
End I
If Text9.Text <> "" The
drCurrent("Conn ector#") = Text9.Tex
End I
drCurrent("Weig ht") = Val(Text7.Text
drCurrent("Leng th") = Val(Text9.Text
drCurrent("Shou lderTorque") = "0.0
drCurrent("Delt aTorque") = "0.0
drCurrent("MaxT orque") = "0.0
drCurrent("Prod uctionDate") = Toda
drCurrent("Prod uctionTime") = TimeOfDa
drCurrent("Oper atorName") = Text27.Tex
drCurrent("Trai lerID") = Text16.Tex
drCurrent("Trai lerLoad#") = Val(TextBox1.Te xt
tblQAData.Rows. Add(drCurrent
Previous attempt was to create 5 datagrids with visible set to "false", each one of which would have updated an appropriate table, but could not find a way to write the data in the text boxes to a datagrid

I forget what else I have tried. Very open to suggestions, very frustrated by the extreme granulation of the help files, in that they show too small of a segment to really understand the overall process

Thanks in advance

Leon
Nov 20 '05 #1
4 1461
One of the biggest changes from ADO to ADO.net is the disconnected model
that ADO.Net employs. This means that where in ADO, when you added or
altered a row, it wrote to the database. In ADO.Net, when you add or alter a
row, it just writes the data to the DataTable. To get the data actually
written to the database you will need to use a DataAdapter. You probably
used one to fill up the DataTable you are currently using.

I will assume a DataSet named PipeData1 and an OledbDataAdapte r named
PipeDataAdapt
-----------------------
Dim PipeDataAdapt as new OleDbDataAdapte r("select * from mypipetable", cn)
Dim PipeData1 as new DataSet

PipeDataAdapt.F ill(PipeData1)

' all your code here, including the add statement.

' now, to get the data back to the db

Dim cb as new OledbCommandBui lder(PipeDataAd apt)
PipeDataAdapt.U pdate(PipeData1 )
------------------------

This is a little rough, but the idea is that you can use an
OleDbCommandBui lder to create the update,insert,d elete statements needed to
get the data back to the table. Then let the DataAdapter do the actual
work. I can give you some more specifics if you can post some code.


"Leon.Kemp" <le*******@hunt ing-intl.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a project that I am working on that will (ultimately) write to 2 Excel Spreadsheets, 3 Access databases, and communicates with 3 other
programs (torque monitoring software, a laser rangefinder, and a specialized
industrial inkjet printer). I had much of it working in VB6, but then
upgraded (for reasons that I can no longer remember) to .NET. I am now
having problems communicating to Access. The main form has 35 text boxes on
it fo an operator interface, and using a series of datagrids for the
interface is not an option, as this would truely confuse the end users.
It seems that most of the material in MSDN assumes that you are using SQL server. Very little is written for Access. This has made life miserable
for the last 2 weeks. I should also mention that I am primarily a Network
Administrator, but have done some VB programming on the side.
I have tried the following:
Updating the database from a datasest object (Q301248). (This is where I am at, at present) When the program is run, no errors are found, data
column references are accepted, but the database is not updated. Section of
code folllows:
(in Declarations)
Dim drCurrent As DataRow

Dim tblQAData As DataTable

(during Form load)
tblQAData = PipeData1.Table s("QAData")

(process for writing to 1 database)
' Write QA Data for pipe to database
drCurrent = tblQAData.NewRo w
drCurrent("ID") = ""
drCurrent("Work Order") = Text3.Text
If Text25.Text <> "" Then
drCurrent("Tube #") = Text25.Text
End If
If Text5.Text <> "" Then
drCurrent("Heat #") = Text5.Text
End If
If Text9.Text <> "" Then
drCurrent("Conn ector#") = Text9.Text
End If
drCurrent("Weig ht") = Val(Text7.Text)
drCurrent("Leng th") = Val(Text9.Text)
drCurrent("Shou lderTorque") = "0.0"
drCurrent("Delt aTorque") = "0.0"
drCurrent("MaxT orque") = "0.0"
drCurrent("Prod uctionDate") = Today
drCurrent("Prod uctionTime") = TimeOfDay
drCurrent("Oper atorName") = Text27.Text
drCurrent("Trai lerID") = Text16.Text
drCurrent("Trai lerLoad#") = Val(TextBox1.Te xt)
tblQAData.Rows. Add(drCurrent)

Previous attempt was to create 5 datagrids with visible set to "false", each one of which would have updated an appropriate table, but could not
find a way to write the data in the text boxes to a datagrid.
I forget what else I have tried. Very open to suggestions, very frustrated by the extreme granulation of the help files, in that they show
too small of a segment to really understand the overall process.
Thanks in advance,

Leon

Nov 20 '05 #2
"Bob Boran" <mc*******@hotm ail.com> wrote in message news:<OZ******* ******@tk2msftn gp13.phx.gbl>.. .
One of the biggest changes from ADO to ADO.net is the disconnected model
that ADO.Net employs. This means that where in ADO, when you added or
altered a row, it wrote to the database.


Not so. I've always used ADO classic in a disconnected fashion and
only 'write to the database' when the connection has been
re-established e.g.

' Open connection
Connect True

' Set recordset properties
With m_rsMain

' Client-side cursor crucial for disconnected recordset
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOpti mistic
.Source = strSql
.ActiveConnecti on = m_oConn
.Open
.ActiveConnecti on = Nothing ' << disconnect
End With

' Close connection
Connect False

' Do something with disconnected recordset
...

--
Nov 20 '05 #3
Bob

Thanks, that did it. (Although I did not have to use the Dim cb as new OledbCommandBui lder(PipeDataAd apt)) line, as OledbCommandBui lder was not recognized

Very much appreciated

Leon Kem
Nov 20 '05 #4
Hi,

Do you know you can reference ADODB instead and all the pain goes away!

Merlin
"Leon.Kemp" <le*******@hunt ing-intl.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a project that I am working on that will (ultimately) write to 2 Excel Spreadsheets, 3 Access databases, and communicates with 3 other
programs (torque monitoring software, a laser rangefinder, and a specialized
industrial inkjet printer). I had much of it working in VB6, but then
upgraded (for reasons that I can no longer remember) to .NET. I am now
having problems communicating to Access. The main form has 35 text boxes on
it fo an operator interface, and using a series of datagrids for the
interface is not an option, as this would truely confuse the end users.
It seems that most of the material in MSDN assumes that you are using SQL server. Very little is written for Access. This has made life miserable
for the last 2 weeks. I should also mention that I am primarily a Network
Administrator, but have done some VB programming on the side.
I have tried the following:
Updating the database from a datasest object (Q301248). (This is where I am at, at present) When the program is run, no errors are found, data
column references are accepted, but the database is not updated. Section of
code folllows:
(in Declarations)
Dim drCurrent As DataRow

Dim tblQAData As DataTable

(during Form load)
tblQAData = PipeData1.Table s("QAData")

(process for writing to 1 database)
' Write QA Data for pipe to database
drCurrent = tblQAData.NewRo w
drCurrent("ID") = ""
drCurrent("Work Order") = Text3.Text
If Text25.Text <> "" Then
drCurrent("Tube #") = Text25.Text
End If
If Text5.Text <> "" Then
drCurrent("Heat #") = Text5.Text
End If
If Text9.Text <> "" Then
drCurrent("Conn ector#") = Text9.Text
End If
drCurrent("Weig ht") = Val(Text7.Text)
drCurrent("Leng th") = Val(Text9.Text)
drCurrent("Shou lderTorque") = "0.0"
drCurrent("Delt aTorque") = "0.0"
drCurrent("MaxT orque") = "0.0"
drCurrent("Prod uctionDate") = Today
drCurrent("Prod uctionTime") = TimeOfDay
drCurrent("Oper atorName") = Text27.Text
drCurrent("Trai lerID") = Text16.Text
drCurrent("Trai lerLoad#") = Val(TextBox1.Te xt)
tblQAData.Rows. Add(drCurrent)

Previous attempt was to create 5 datagrids with visible set to "false", each one of which would have updated an appropriate table, but could not
find a way to write the data in the text boxes to a datagrid.
I forget what else I have tried. Very open to suggestions, very frustrated by the extreme granulation of the help files, in that they show
too small of a segment to really understand the overall process.
Thanks in advance,

Leon

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4395
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option offered in the table linking dialog. Is there a more direct connection with OLE_DB? John South Pangbourne UK
2
4505
by: Jeff Pritchard | last post by:
Some time ago I am sure I came across something that said this was possible, though it doesn't seem to work. A client wants to replace an Access back-end with SQL Server tables. We have tried linking the SQL tables to an Access back-end and then linking the linked tables in the Access back-end to the Access front-end. Doesn't work at all. Obviously, this can't be done. What is the best way to replace an Access back-end with SQL tables?
0
2248
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database that is used to connect to other databases and generate reports. below is sample code of how the database does the linking i hope i give you enough info to help me but if not let me know and i will give more. Sub txtShipDataFileSub() Dim...
18
3091
by: Mark P | last post by:
I have a bit of vb code that uses Tables.Append to programatically link tables from Oracle and DB2 datasources. The problem I am having on some client machines is that the link will take anywhere from 1 to 3 minutes to link the table. When I manually link the tables,through Access, it takes no time at all. Note that only certain client have the problem, and the problem will sometimes go away. These clients will usually get an ODBC Call...
2
4141
by: Matthew Wells | last post by:
Good morning... I have an Access front end that uses SQL Server linked tables. SQL Server uses Windows authentication. I have one Windows group that all Access users are a member of. I added that group to SQL Server logins and gave it public, datareader, and datawriter rights to the one database that's used. My front end is locked down, but I want to stop users from creating a new ..mdb and linking SQL Server tables through DSNs or...
1
1542
by: GregZ | last post by:
I have an Access 97 database that I have uploaded to the internet. I have created a DSN for it with the hosting company and can now access it using .asp code. Everything here works fine. But, I would also like to be able to access the database by "linking" to it in Access. I did something like this a couple of years ago with an SQL Server database. I don't remember how I made the (ODBC?) connection then. (Actually, I think I just fumbled...
7
3061
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro 2.0;HDR=NO;IMEX=2;DATABASE=C:\Test It's really easy to connect to those tables in A97. I'm having difficulties in A2003. I'm trying to follow the instructions in http://support.microsoft.com/kb/824264/.
0
2408
by: hivdb2 | last post by:
Hi all, I have an app developed in Access 2000/2003 (2000 compatible). I have a routine to refresh table links. Both files are MDB files (the front end and back end). The code I use is as follows: DoCmd.TransferDatabase acLink, "Microsoft Access", datafile, acForm, table, table datafile = "c:\mydir\mybackend.mdb" The file that contains the code is c:\mydir\myfrontent.mdb
1
2328
by: agarwasa2008 | last post by:
Hi, I have a perfect file called "Products.xls" that I link to my MS Access 2003 database and everytthing looks good in that file. When I view the same file after linking in my database the data values of records in "tblProducts" are incorrect. For example the tblProducts has a field called "PackageSize" as listed below. THe problem is that it displays the text correctly but if the field has numbers only it messes it up. I have set...
7
2865
by: coolsti | last post by:
I have the task to set up an application at work,using MS Access as a front end to a MySQL database. This will be done using an appropriate ODBC driver, and linking the MySQL database to Access. My question is whether it is possible to set something up so that when linking to the MySQL database, the user name which is used for the MySQL connection is taken as the user's Windows ID. If so, then I can set up users and access grants in MySQL...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.