473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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.Tables("QAData"

(process for writing to 1 database
' Write QA Data for pipe to databas
drCurrent = tblQAData.NewRo
drCurrent("ID") = "
drCurrent("WorkOrder") = 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("Connector#") = Text9.Tex
End I
drCurrent("Weight") = Val(Text7.Text
drCurrent("Length") = Val(Text9.Text
drCurrent("ShoulderTorque") = "0.0
drCurrent("DeltaTorque") = "0.0
drCurrent("MaxTorque") = "0.0
drCurrent("ProductionDate") = Toda
drCurrent("ProductionTime") = TimeOfDa
drCurrent("OperatorName") = Text27.Tex
drCurrent("TrailerID") = Text16.Tex
drCurrent("TrailerLoad#") = Val(TextBox1.Text
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 1449
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 OledbDataAdapter named
PipeDataAdapt
-----------------------
Dim PipeDataAdapt as new OleDbDataAdapter("select * from mypipetable", cn)
Dim PipeData1 as new DataSet

PipeDataAdapt.Fill(PipeData1)

' all your code here, including the add statement.

' now, to get the data back to the db

Dim cb as new OledbCommandBuilder(PipeDataAdapt)
PipeDataAdapt.Update(PipeData1)
------------------------

This is a little rough, but the idea is that you can use an
OleDbCommandBuilder to create the update,insert,delete 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*******@hunting-intl.com> wrote in message
news:E3**********************************@microsof t.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.Tables("QAData")

(process for writing to 1 database)
' Write QA Data for pipe to database
drCurrent = tblQAData.NewRow
drCurrent("ID") = ""
drCurrent("WorkOrder") = 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("Connector#") = Text9.Text
End If
drCurrent("Weight") = Val(Text7.Text)
drCurrent("Length") = Val(Text9.Text)
drCurrent("ShoulderTorque") = "0.0"
drCurrent("DeltaTorque") = "0.0"
drCurrent("MaxTorque") = "0.0"
drCurrent("ProductionDate") = Today
drCurrent("ProductionTime") = TimeOfDay
drCurrent("OperatorName") = Text27.Text
drCurrent("TrailerID") = Text16.Text
drCurrent("TrailerLoad#") = Val(TextBox1.Text)
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*******@hotmail.com> wrote in message news:<OZ*************@tk2msftngp13.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 = adLockBatchOptimistic
.Source = strSql
.ActiveConnection = m_oConn
.Open
.ActiveConnection = 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 OledbCommandBuilder(PipeDataAdapt)) line, as OledbCommandBuilder 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*******@hunting-intl.com> wrote in message
news:E3**********************************@microsof t.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.Tables("QAData")

(process for writing to 1 database)
' Write QA Data for pipe to database
drCurrent = tblQAData.NewRow
drCurrent("ID") = ""
drCurrent("WorkOrder") = 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("Connector#") = Text9.Text
End If
drCurrent("Weight") = Val(Text7.Text)
drCurrent("Length") = Val(Text9.Text)
drCurrent("ShoulderTorque") = "0.0"
drCurrent("DeltaTorque") = "0.0"
drCurrent("MaxTorque") = "0.0"
drCurrent("ProductionDate") = Today
drCurrent("ProductionTime") = TimeOfDay
drCurrent("OperatorName") = Text27.Text
drCurrent("TrailerID") = Text16.Text
drCurrent("TrailerLoad#") = Val(TextBox1.Text)
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
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...
2
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...
0
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...
18
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...
2
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...
1
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...
7
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...
0
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...
1
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...
7
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.