I am making the switch to .NET from VB6. In VB6 you could access data
by using the Data Environment and Data Control. I found both to be
totally useless. I can just as easily accomplish the same task with
code. For example if I wanted to populate a textbox I would do
something like this:
Dim rst As New Recordset
Dim cnn as New Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\test\test.mdb;"
rst.Open "Select * From Table1", cnn
Text1.Text = rst!Field1
Using code, in my opinion, is much easier and more flexible than using
the Data Environment Wizard and the data control. Plus you can use in
in your VBA macros.
I have a tutorial on .NET but it seems to only cover .NET's version of
the Data Environment and Data control. I think they call it the Server
Explorer and Data Adapter.
Is there a way to access data using straight VB code like I did in
VB6?
Thanks!
Chuck. 11 4059
You can do the same in .NET (which I prefer over those
drag and drop wizards):
Dim cnn As OleDbConnection = New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\test\test.mdb;")
cnn.Open()
Dim cmd As OleDbCommand = New OleDbCommand("Select * From
Table1", cnn)
Dim rdr As OleDbDataReader = cmd.ExecuteReader()
If rdr.Read() Then
Text1.Text = rdr(0)
End If
Bin Song, MCP -----Original Message----- I am making the switch to .NET from VB6. In VB6 you could
access databy using the Data Environment and Data Control. I found
both to betotally useless. I can just as easily accomplish the same
task withcode. For example if I wanted to populate a textbox I
would dosomething like this:
Dim rst As New Recordset Dim cnn as New Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;" rst.Open "Select * From Table1", cnn Text1.Text = rst!Field1
Using code, in my opinion, is much easier and more
flexible than usingthe Data Environment Wizard and the data control. Plus
you can use inin your VBA macros.
I have a tutorial on .NET but it seems to only
cover .NET's version ofthe Data Environment and Data control. I think they call
it the ServerExplorer and Data Adapter.
Is there a way to access data using straight VB code like
I did inVB6?
Thanks!
Chuck. .
Hi CR,
In addition to Bing Song a little sample, how to use it with a dataset
Just typed from your example, so watch typos.
\\\\ dim connString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;"
dim SqlString as string = "Select * From Table1"
Dim conn As New OledbConnection(connString)
Dim cmd As New OleDbCommand(sqlStr, Conn)
Dim ds As New DataSet
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, "Table1")
conn.close
///
I hope this helps a little bit.
Cor
"Bin Song" <an*******@discussions.microsoft.com> wrote in message news:<02****************************@phx.gbl>...
Thanks! That saves me a lot of trouble. You can do the same in .NET (which I prefer over those drag and drop wizards):
Dim cnn As OleDbConnection = New OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\test\test.mdb;") cnn.Open() Dim cmd As OleDbCommand = New OleDbCommand("Select * From Table1", cnn) Dim rdr As OleDbDataReader = cmd.ExecuteReader() If rdr.Read() Then Text1.Text = rdr(0) End If
Bin Song, MCP
-----Original Message----- I am making the switch to .NET from VB6. In VB6 you could access databy using the Data Environment and Data Control. I found both to betotally useless. I can just as easily accomplish the same task withcode. For example if I wanted to populate a textbox I would dosomething like this:
Dim rst As New Recordset Dim cnn as New Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;" rst.Open "Select * From Table1", cnn Text1.Text = rst!Field1
Using code, in my opinion, is much easier and more flexible than usingthe Data Environment Wizard and the data control. Plus you can use inin your VBA macros.
I have a tutorial on .NET but it seems to only cover .NET's version ofthe Data Environment and Data control. I think they call it the ServerExplorer and Data Adapter.
Is there a way to access data using straight VB code like I did inVB6?
Thanks!
Chuck. .
"Cor" <no*@non.com> wrote in message news:<#9**************@TK2MSFTNGP09.phx.gbl>...
I appreciate the help!
Chuck. Hi CR,
In addition to Bing Song a little sample, how to use it with a dataset Just typed from your example, so watch typos.
\\\\ dim connString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;" dim SqlString as string = "Select * From Table1" Dim conn As New OledbConnection(connString) Dim cmd As New OleDbCommand(sqlStr, Conn) Dim ds As New DataSet Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, "Table1") conn.close ///
I hope this helps a little bit.
Cor
"Cor" <no*@non.com> wrote in message news:<#9**************@TK2MSFTNGP09.phx.gbl>... Hi CR,
In addition to Bing Song a little sample, how to use it with a dataset Just typed from your example, so watch typos.
\\\\ dim connString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;" dim SqlString as string = "Select * From Table1" Dim conn As New OledbConnection(connString) Dim cmd As New OleDbCommand(sqlStr, Conn) Dim ds As New DataSet Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, "Table1") conn.close
I figured out how to access data in the DataReader but I can't figure
out how to access the data in the DataSet. In this example if I had a
field in Table1 called Field1, how would I get to the value in Field1?
"CR" <cr***@hotmail.com> schrieb I figured out how to access data in the DataReader but I can't figure out how to access the data in the DataSet. In this example if I had a field in Table1 called Field1, how would I get to the value in Field1?
Only a question: Have you already read the documentation of the DataSet (and
other ADO.NET related topics)?
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html I figured out how to access data in the DataReader but I can't figure out how to access the data in the DataSet. In this example if I had a field in Table1 called Field1, how would I get to the value in Field1?
For the first record(row)
ds.tables(0).rows(0).item("Field1")
"> > \\\\ dim connString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;" dim SqlString as string = "Select * From Table1" Dim conn As New OledbConnection(connString) Dim cmd As New OleDbCommand(sqlStr, Conn) Dim ds As New DataSet Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, "Table1") conn.close
"Armin Zingler" <az*******@freenet.de> wrote in message news:<e2*************@TK2MSFTNGP09.phx.gbl>... "CR" <cr***@hotmail.com> schrieb I figured out how to access data in the DataReader but I can't figure out how to access the data in the DataSet. In this example if I had a field in Table1 called Field1, how would I get to the value in Field1?
Only a question: Have you already read the documentation of the DataSet (and other ADO.NET related topics)?
Some of the online help, but it's a little overwhelming. For example
I'm not sure if I should even be using the DataSet object, maybe I
only need the DataReader. What documentation would you recommend I
read to get a good overview of this topic?
"Cor" <no*@non.com> wrote in message news:<e0**************@TK2MSFTNGP09.phx.gbl>... I figured out how to access data in the DataReader but I can't figure out how to access the data in the DataSet. In this example if I had a field in Table1 called Field1, how would I get to the value in Field1?
For the first record(row)
ds.tables(0).rows(0).item("Field1")
Works! Thanks!
Chuck.
"CR" <cr***@hotmail.com> schrieb "Armin Zingler" <az*******@freenet.de> wrote in message news:<e2*************@TK2MSFTNGP09.phx.gbl>... "CR" <cr***@hotmail.com> schrieb I figured out how to access data in the DataReader but I can't figure out how to access the data in the DataSet. In this example if I had a field in Table1 called Field1, how would I get to the value in Field1?
Only a question: Have you already read the documentation of the DataSet (and other ADO.NET related topics)?
Some of the online help, but it's a little overwhelming. For example I'm not sure if I should even be using the DataSet object, maybe I only need the DataReader. What documentation would you recommend I read to get a good overview of this topic?
Concerning the Dataset I recommend http://msdn.microsoft.com/library/en...ngdatasets.asp http://msdn.microsoft.com/library/en...riDatasets.asp
If you only want to process data from the database sequentially, you can use
a DataReader. As the name says, it is used to read the data from the
databse. A dataset is an object that locally stores the content of the
records read, and you'll be able to access the records randomly.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Armin Zingler" <az*******@freenet.de> wrote in message Some of the online help, but it's a little overwhelming. For example I'm not sure if I should even be using the DataSet object, maybe I only need the DataReader. What documentation would you recommend I read to get a good overview of this topic?
Concerning the Dataset I recommend http://msdn.microsoft.com/library/en...ngdatasets.asp http://msdn.microsoft.com/library/en...riDatasets.asp
If you only want to process data from the database sequentially, you can use a DataReader. As the name says, it is used to read the data from the databse. A dataset is an object that locally stores the content of the records read, and you'll be able to access the records randomly.
I just found a good book that also has a nice summary of the dataset
object. I hate to ask stupid questions but I'm in that awkward "just
starting" phase where you don't even know what questions to ask let
alone the answers.
Thanks!
Chuck. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marco Alting |
last post by:
Is it possible to INNER JOIN two recordsets in ASP? I don't mean the normal
JOIN you would use with two tables, but actually join the recordsets in ASP?
|
by: Steve Marciniak |
last post by:
I'm trying to display different recordsets (which are 1 field each) as
columns right next to one another. For example, Recordset1 is
displayed on the left hand side of the screen. Recordset2 is...
|
by: Steve Jorgensen |
last post by:
I keep having problems in which ADO disconnected recordset work under some
circumstances, but lose all their data at other times, having no rows or
fields, though the recordset object still exists....
|
by: Pieter Linden |
last post by:
The answer to this one is probably "test it yourself and find out!",
but I'll ask anyway. Pursuant to my previous question - sending
separate recordsets to Word using the CreateTableFromRecordset...
|
by: lakshmi |
last post by:
Hi all,
I recently rewrote a data intensive C++ program in C#.
The C++ program was traversing 3 recordsets that were all
open at the same time. I replaced those 3 recordsets with
3 .NET data...
|
by: Randy Harris |
last post by:
I was inspired by the recent discussion of returning multiple recordsets to
ADO from a stored procedure. (Amazed is probably more accurate). I asked
about how to accomplish same with Oracle and...
|
by: Donald Grove |
last post by:
I want to populate an array with values from an ado recordset
(multiple rows)
I use the absolute position of the cursor in the recordset to define
the row of my array to be populated. I have a...
|
by: mrmagoo |
last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server
database.
One of the main goals of the project is to be really responsive to events,
such as textbox change events. I...
|
by: rdemyan via AccessMonster.com |
last post by:
Can someone help me with creating code that will look for DAO recordsets in
modules and then check to see if the recordset is also closed in the module.
All of my recordsets are of the form rs*...
|
by: BeckR |
last post by:
Hello - Thanks for reading my post.
I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now.
I have an Access 2000 database (running WinXP Pro...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |