Connecting to a DataBase like i did in VB 6 | | |
Hi all,
I wrote a cool little database program a while back, in VB6, and im
intending to rewrite it in .net.
I am new(ish) to .net, but an old hand at VB5/6.
In VB i would access the mdb file something like this.
set db=database
set db=opendatabase("mydb.mdb")
dim rec as recordset
set rec= db.openrecordset("select name form names")
while rec.eof=false
debug.write(rec!name)
wend
How do i do the same in .net, it seems to want me to set up these pages ets,
but i need to create queries and joins on the fly so data can be accessed as
the user requests.
Ive looked in the help, and followed the tutorials, but i cant seem to be
able to query the db properly, or even connect to it in the way that i want.
Thanks in advance
Chris | | | | re: Connecting to a DataBase like i did in VB 6
Use the OleDdDataAdapter, Connection and Command controls in winforms to
generate the strings that you require for your app. To manipulate these
strings programmatically try using the stringbuilder class.
"Chris" <xcmharb@lineone.net> wrote in message
news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...[color=blue]
> Hi all,
>
> I wrote a cool little database program a while back, in VB6, and im
> intending to rewrite it in .net.
>
> I am new(ish) to .net, but an old hand at VB5/6.
>
> In VB i would access the mdb file something like this.
>
> set db=database
> set db=opendatabase("mydb.mdb")
> dim rec as recordset
> set rec= db.openrecordset("select name form names")
>
> while rec.eof=false
> debug.write(rec!name)
> wend
>
>
> How do i do the same in .net, it seems to want me to set up these pages[/color]
ets,[color=blue]
> but i need to create queries and joins on the fly so data can be accessed[/color]
as[color=blue]
> the user requests.
>
> Ive looked in the help, and followed the tutorials, but i cant seem to be
> able to query the db properly, or even connect to it in the way that i[/color]
want.[color=blue]
>
> Thanks in advance
>
> Chris
>
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Can you give a code example that does teh same as my code below please.
"Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...[color=blue]
> Use the OleDdDataAdapter, Connection and Command controls in winforms to
> generate the strings that you require for your app. To manipulate these
> strings programmatically try using the stringbuilder class.
>
> "Chris" <xcmharb@lineone.net> wrote in message
> news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...[color=green]
> > Hi all,
> >
> > I wrote a cool little database program a while back, in VB6, and im
> > intending to rewrite it in .net.
> >
> > I am new(ish) to .net, but an old hand at VB5/6.
> >
> > In VB i would access the mdb file something like this.
> >
> > set db=database
> > set db=opendatabase("mydb.mdb")
> > dim rec as recordset
> > set rec= db.openrecordset("select name form names")
> >
> > while rec.eof=false
> > debug.write(rec!name)[/color][/color]
rec.movenext[color=blue][color=green]
> > wend
> >
> >
> > How do i do the same in .net, it seems to want me to set up these pages[/color]
> ets,[color=green]
> > but i need to create queries and joins on the fly so data can be[/color][/color]
accessed[color=blue]
> as[color=green]
> > the user requests.
> >
> > Ive looked in the help, and followed the tutorials, but i cant seem to[/color][/color]
be[color=blue][color=green]
> > able to query the db properly, or even connect to it in the way that i[/color]
> want.[color=green]
> >
> > Thanks in advance
> >
> > Chris
> >
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Chris,
Without all error checking.
\\\
Dim ds as new dataset
Dim Conn As New OleDbConnection(Microsoft.Jet.OLEDB.4.0;Data
Source="C:\mydb.Mdb")
Dim da As New OleDbDataAdapter("Select name from names",Conn)
da.Fill(ds)
for each dr as datarow in ds.tables(0).rows
console.write(dr("name").ToString)
next
////
I hope this helps?
Cor
[color=blue]
>
> I wrote a cool little database program a while back, in VB6, and im
> intending to rewrite it in .net.
>
> I am new(ish) to .net, but an old hand at VB5/6.
>
> In VB i would access the mdb file something like this.
>
> set db=database
> set db=opendatabase("mydb.mdb")
> dim rec as recordset
> set rec= db.openrecordset("select name form names")
>
> while rec.eof=false
> debug.write(rec!name)
> wend
>
>
> How do i do the same in .net, it seems to want me to set up these pages[/color]
ets,[color=blue]
> but i need to create queries and joins on the fly so data can be accessed[/color]
as[color=blue]
> the user requests.
>
> Ive looked in the help, and followed the tutorials, but i cant seem to be
> able to query the db properly, or even connect to it in the way that i[/color]
want.[color=blue]
>
> Thanks in advance
>
> Chris
>
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Something like this:
Dim mydbConnection As OleDb.OleDbConnection
mydbConnection.ConnectionString = "c:\mydb.mdb"
mydbConnection.Open()
Dim mydbCommand As OleDb.OleDbCommand
mydbCommand.Connection = mydbConnection
mydbCommand.CommandText = "SELECT * FROM MyTable"
Dim myreader As oleDB.OleDbDataReader
myreader = mydbCommand.ExecuteReader
You can now inspect the myreader object the same way as you did with your
recordset.
"Chris" <xcmharb@lineone.net> wrote in message
news:e5K2avXdEHA.2408@tk2msftngp13.phx.gbl...[color=blue]
> Can you give a code example that does teh same as my code below please.
>
>
> "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...[color=green]
> > Use the OleDdDataAdapter, Connection and Command controls in winforms[/color][/color]
to[color=blue][color=green]
> > generate the strings that you require for your app. To manipulate these
> > strings programmatically try using the stringbuilder class.
> >
> > "Chris" <xcmharb@lineone.net> wrote in message
> > news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi all,
> > >
> > > I wrote a cool little database program a while back, in VB6, and im
> > > intending to rewrite it in .net.
> > >
> > > I am new(ish) to .net, but an old hand at VB5/6.
> > >
> > > In VB i would access the mdb file something like this.
> > >
> > > set db=database
> > > set db=opendatabase("mydb.mdb")
> > > dim rec as recordset
> > > set rec= db.openrecordset("select name form names")
> > >
> > > while rec.eof=false
> > > debug.write(rec!name)[/color][/color]
> rec.movenext[color=green][color=darkred]
> > > wend
> > >
> > >
> > > How do i do the same in .net, it seems to want me to set up these[/color][/color][/color]
pages[color=blue][color=green]
> > ets,[color=darkred]
> > > but i need to create queries and joins on the fly so data can be[/color][/color]
> accessed[color=green]
> > as[color=darkred]
> > > the user requests.
> > >
> > > Ive looked in the help, and followed the tutorials, but i cant seem to[/color][/color]
> be[color=green][color=darkred]
> > > able to query the db properly, or even connect to it in the way that i[/color]
> > want.[color=darkred]
> > >
> > > Thanks in advance
> > >
> > > Chris
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Thanks Nick thats great, but how do i get at the data?
eg.
debug.writeline(myreader!name)
just throws an error. AAh i know what i wnnt, but not how to sintax it.
BTW, all the objects need to be new(ed) on the dims.
"Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
news:%23Q$CSNYdEHA.1048@tk2msftngp13.phx.gbl...[color=blue]
> Something like this:
>
> Dim mydbConnection As OleDb.OleDbConnection
> mydbConnection.ConnectionString = "c:\mydb.mdb"
> mydbConnection.Open()
>
> Dim mydbCommand As OleDb.OleDbCommand
> mydbCommand.Connection = mydbConnection
> mydbCommand.CommandText = "SELECT * FROM MyTable"
>
> Dim myreader As oleDB.OleDbDataReader
>
> myreader = mydbCommand.ExecuteReader
>
> You can now inspect the myreader object the same way as you did with your
> recordset.
>
> "Chris" <xcmharb@lineone.net> wrote in message
> news:e5K2avXdEHA.2408@tk2msftngp13.phx.gbl...[color=green]
> > Can you give a code example that does teh same as my code below please.
> >
> >
> > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Use the OleDdDataAdapter, Connection and Command controls in winforms[/color][/color]
> to[color=green][color=darkred]
> > > generate the strings that you require for your app. To manipulate[/color][/color][/color]
these[color=blue][color=green][color=darkred]
> > > strings programmatically try using the stringbuilder class.
> > >
> > > "Chris" <xcmharb@lineone.net> wrote in message
> > > news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...
> > > > Hi all,
> > > >
> > > > I wrote a cool little database program a while back, in VB6, and im
> > > > intending to rewrite it in .net.
> > > >
> > > > I am new(ish) to .net, but an old hand at VB5/6.
> > > >
> > > > In VB i would access the mdb file something like this.
> > > >
> > > > set db=database
> > > > set db=opendatabase("mydb.mdb")
> > > > dim rec as recordset
> > > > set rec= db.openrecordset("select name form names")
> > > >
> > > > while rec.eof=false
> > > > debug.write(rec!name)[/color]
> > rec.movenext[color=darkred]
> > > > wend
> > > >
> > > >
> > > > How do i do the same in .net, it seems to want me to set up these[/color][/color]
> pages[color=green][color=darkred]
> > > ets,
> > > > but i need to create queries and joins on the fly so data can be[/color]
> > accessed[color=darkred]
> > > as
> > > > the user requests.
> > > >
> > > > Ive looked in the help, and followed the tutorials, but i cant seem[/color][/color][/color]
to[color=blue][color=green]
> > be[color=darkred]
> > > > able to query the db properly, or even connect to it in the way that[/color][/color][/color]
i[color=blue][color=green][color=darkred]
> > > want.
> > > >
> > > > Thanks in advance
> > > >
> > > > Chris
> > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Chris,
Use
Do While myreader.Read ' assuming I've got the VB syntax for this
loop
Dim myVar AS string = myreader.GetString(0) ' for a string at the
first field returned
' also see GetOrdinal to lookup the column #
from the name
Dim myInt AS int =
myreader.GetInt32(myreader.GetOrdinal("myFieldName "))
Loop
Ron Allen
"Chris" <xcmharb@lineone.net> wrote in message
news:uLWEkcZdEHA.2384@TK2MSFTNGP09.phx.gbl...[color=blue]
>
> Thanks Nick thats great, but how do i get at the data?
>
> eg.
>
> debug.writeline(myreader!name)
>
> just throws an error. AAh i know what i wnnt, but not how to sintax it.
>
> BTW, all the objects need to be new(ed) on the dims.
>
> "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> news:%23Q$CSNYdEHA.1048@tk2msftngp13.phx.gbl...[color=green]
> > Something like this:
> >
> > Dim mydbConnection As OleDb.OleDbConnection
> > mydbConnection.ConnectionString = "c:\mydb.mdb"
> > mydbConnection.Open()
> >
> > Dim mydbCommand As OleDb.OleDbCommand
> > mydbCommand.Connection = mydbConnection
> > mydbCommand.CommandText = "SELECT * FROM MyTable"
> >
> > Dim myreader As oleDB.OleDbDataReader
> >
> > myreader = mydbCommand.ExecuteReader
> >
> > You can now inspect the myreader object the same way as you did with[/color][/color]
your[color=blue][color=green]
> > recordset.
> >
> > "Chris" <xcmharb@lineone.net> wrote in message
> > news:e5K2avXdEHA.2408@tk2msftngp13.phx.gbl...[color=darkred]
> > > Can you give a code example that does teh same as my code below[/color][/color][/color]
please.[color=blue][color=green][color=darkred]
> > >
> > >
> > > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > > news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...
> > > > Use the OleDdDataAdapter, Connection and Command controls in[/color][/color][/color]
winforms[color=blue][color=green]
> > to[color=darkred]
> > > > generate the strings that you require for your app. To manipulate[/color][/color]
> these[color=green][color=darkred]
> > > > strings programmatically try using the stringbuilder class.
> > > >
> > > > "Chris" <xcmharb@lineone.net> wrote in message
> > > > news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...
> > > > > Hi all,
> > > > >
> > > > > I wrote a cool little database program a while back, in VB6, and[/color][/color][/color]
im[color=blue][color=green][color=darkred]
> > > > > intending to rewrite it in .net.
> > > > >
> > > > > I am new(ish) to .net, but an old hand at VB5/6.
> > > > >
> > > > > In VB i would access the mdb file something like this.
> > > > >
> > > > > set db=database
> > > > > set db=opendatabase("mydb.mdb")
> > > > > dim rec as recordset
> > > > > set rec= db.openrecordset("select name form names")
> > > > >
> > > > > while rec.eof=false
> > > > > debug.write(rec!name)
> > > rec.movenext
> > > > > wend
> > > > >
> > > > >
> > > > > How do i do the same in .net, it seems to want me to set up these[/color]
> > pages[color=darkred]
> > > > ets,
> > > > > but i need to create queries and joins on the fly so data can be
> > > accessed
> > > > as
> > > > > the user requests.
> > > > >
> > > > > Ive looked in the help, and followed the tutorials, but i cant[/color][/color][/color]
seem[color=blue]
> to[color=green][color=darkred]
> > > be
> > > > > able to query the db properly, or even connect to it in the way[/color][/color][/color]
that[color=blue]
> i[color=green][color=darkred]
> > > > want.
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > > Chris
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Sorry ron but that does nothing but throw erreors.
I think i am missing a consecpt here, or .NET has taken DB programing and
made it so trikey that no one can use it propperly.
All i wnat is this translated into .NET, ive just complied it and got it
running in VB6, took me 5mins. In fact it took me less time to write that
code than it did to write this message. Unlike 2+ days for .NET to do the
same thing and still no joy.
here is excatly what i wnat converted, i need the VAR names to remain if
possible.
db.mdb has one table (Users) with 2 collums, (Name, Password)
///
dim DB as Database ' i wnat to use the db everywher in the program so i
only want to open it once.
sub main()
set DB = opendatabase("C:\db.mdb") 'open DB
dim qry as string = "Select * from users;" 'set query
dim usr as recordset 'create an empty
record set
set usr = db.openrecordset(qry) ' populate record set
while usr.eof = false ' loop unless
end of record set is reached
debug.writeline(usr!Name) 'dump name from
current record
debug.writeline(usr!Password) 'dump password from
current record
usr.movenext 'move to
next record
end while.
end sub
///
how can this be so diffacult in .NET !!!
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:ex8YVRjdEHA.3928@TK2MSFTNGP09.phx.gbl...[color=blue]
> Chris,
> Use
> Do While myreader.Read ' assuming I've got the VB syntax for this
> loop
> Dim myVar AS string = myreader.GetString(0) ' for a string at[/color]
the[color=blue]
> first field returned
> ' also see GetOrdinal to lookup the column #
> from the name
> Dim myInt AS int =
> myreader.GetInt32(myreader.GetOrdinal("myFieldName "))
> Loop
>
> Ron Allen
> "Chris" <xcmharb@lineone.net> wrote in message
> news:uLWEkcZdEHA.2384@TK2MSFTNGP09.phx.gbl...[color=green]
> >
> > Thanks Nick thats great, but how do i get at the data?
> >
> > eg.
> >
> > debug.writeline(myreader!name)
> >
> > just throws an error. AAh i know what i wnnt, but not how to sintax it.
> >
> > BTW, all the objects need to be new(ed) on the dims.
> >
> > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > news:%23Q$CSNYdEHA.1048@tk2msftngp13.phx.gbl...[color=darkred]
> > > Something like this:
> > >
> > > Dim mydbConnection As OleDb.OleDbConnection
> > > mydbConnection.ConnectionString = "c:\mydb.mdb"
> > > mydbConnection.Open()
> > >
> > > Dim mydbCommand As OleDb.OleDbCommand
> > > mydbCommand.Connection = mydbConnection
> > > mydbCommand.CommandText = "SELECT * FROM MyTable"
> > >
> > > Dim myreader As oleDB.OleDbDataReader
> > >
> > > myreader = mydbCommand.ExecuteReader
> > >
> > > You can now inspect the myreader object the same way as you did with[/color][/color]
> your[color=green][color=darkred]
> > > recordset.
> > >
> > > "Chris" <xcmharb@lineone.net> wrote in message
> > > news:e5K2avXdEHA.2408@tk2msftngp13.phx.gbl...
> > > > Can you give a code example that does teh same as my code below[/color][/color]
> please.[color=green][color=darkred]
> > > >
> > > >
> > > > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > > > news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...
> > > > > Use the OleDdDataAdapter, Connection and Command controls in[/color][/color]
> winforms[color=green][color=darkred]
> > > to
> > > > > generate the strings that you require for your app. To manipulate[/color]
> > these[color=darkred]
> > > > > strings programmatically try using the stringbuilder class.
> > > > >
> > > > > "Chris" <xcmharb@lineone.net> wrote in message
> > > > > news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...
> > > > > > Hi all,
> > > > > >
> > > > > > I wrote a cool little database program a while back, in VB6, and[/color][/color]
> im[color=green][color=darkred]
> > > > > > intending to rewrite it in .net.
> > > > > >
> > > > > > I am new(ish) to .net, but an old hand at VB5/6.
> > > > > >
> > > > > > In VB i would access the mdb file something like this.
> > > > > >
> > > > > > set db=database
> > > > > > set db=opendatabase("mydb.mdb")
> > > > > > dim rec as recordset
> > > > > > set rec= db.openrecordset("select name form names")
> > > > > >
> > > > > > while rec.eof=false
> > > > > > debug.write(rec!name)
> > > > rec.movenext
> > > > > > wend
> > > > > >
> > > > > >
> > > > > > How do i do the same in .net, it seems to want me to set up[/color][/color][/color]
these[color=blue][color=green][color=darkred]
> > > pages
> > > > > ets,
> > > > > > but i need to create queries and joins on the fly so data can be
> > > > accessed
> > > > > as
> > > > > > the user requests.
> > > > > >
> > > > > > Ive looked in the help, and followed the tutorials, but i cant[/color][/color]
> seem[color=green]
> > to[color=darkred]
> > > > be
> > > > > > able to query the db properly, or even connect to it in the way[/color][/color]
> that[color=green]
> > i[color=darkred]
> > > > > want.
> > > > > >
> > > > > > Thanks in advance
> > > > > >
> > > > > > Chris
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Chris,
It doesn't seem that difficult to me. In C# I'd write
void main() // or some other function called at startup.
{
string connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db.mdb;Mode=Share Deny None;";
OleDbConnection db = new OleDbConnection(connStr)
OleDbCommand cmd = new OleDbCommand("Select Name, Password FROM Users",
db);
_db.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
System.Diagnostics.Debug.WriteLine(rdr.GetString(0 ));
System.Diagnostics.Debug.WriteLine(rdr.GetString(1 ));
}
_db.Close(); // close the connection
}
Note that to use the db variable in other modules you will have to make it
public and specific to the module and pass the class it is in to those
programs. Also make sure that your main doesn't just return after writing
these as that will cause the program to exit. I do this by having my own
class for doing database manipulation. I pass in an open connection or a
database name/server nam (filename for OleDb) and then do all the
manipulation there.
You may want to visit microsoft.public.dotnet.framework.adonet as that
is dedicated to ADO.NET questions.
Also the book by David Sceppa "ADO.NET Core Reference" is quite good and
has a lot of examples in both C# and VB.NET
Ron Allen
"Chris" <xcmharb@lineone.net> wrote in message
news:u$RYd2jdEHA.3732@TK2MSFTNGP11.phx.gbl...[color=blue]
> Sorry ron but that does nothing but throw erreors.
>
> I think i am missing a consecpt here, or .NET has taken DB programing and
> made it so trikey that no one can use it propperly.
>
> All i wnat is this translated into .NET, ive just complied it and got it
> running in VB6, took me 5mins. In fact it took me less time to write that
> code than it did to write this message. Unlike 2+ days for .NET to do the
> same thing and still no joy.
>
> here is excatly what i wnat converted, i need the VAR names to remain if
> possible.
> db.mdb has one table (Users) with 2 collums, (Name, Password)
>
>
> ///
> dim DB as Database ' i wnat to use the db everywher in the program so i
> only want to open it once.
>
> sub main()
>
> set DB = opendatabase("C:\db.mdb") 'open DB
>
> dim qry as string = "Select * from users;" 'set query
> dim usr as recordset 'create an[/color]
empty[color=blue]
> record set
>
> set usr = db.openrecordset(qry) ' populate record set
>
> while usr.eof = false ' loop[/color]
unless[color=blue]
> end of record set is reached
> debug.writeline(usr!Name) 'dump name from
> current record
> debug.writeline(usr!Password) 'dump password from
> current record
> usr.movenext 'move to
> next record
> end while.
>
> end sub
> ///
>
> how can this be so diffacult in .NET !!!
>
>
>
>
>
>
>
>
>
>
>
> "Ron Allen" <rallen@_nospam_src-us.com> wrote in message
> news:ex8YVRjdEHA.3928@TK2MSFTNGP09.phx.gbl...[color=green]
> > Chris,
> > Use
> > Do While myreader.Read ' assuming I've got the VB syntax for this
> > loop
> > Dim myVar AS string = myreader.GetString(0) ' for a string at[/color]
> the[color=green]
> > first field returned
> > ' also see GetOrdinal to lookup the column #
> > from the name
> > Dim myInt AS int =
> > myreader.GetInt32(myreader.GetOrdinal("myFieldName "))
> > Loop
> >
> > Ron Allen
> > "Chris" <xcmharb@lineone.net> wrote in message
> > news:uLWEkcZdEHA.2384@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > >
> > > Thanks Nick thats great, but how do i get at the data?
> > >
> > > eg.
> > >
> > > debug.writeline(myreader!name)
> > >
> > > just throws an error. AAh i know what i wnnt, but not how to sintax[/color][/color][/color]
it.[color=blue][color=green][color=darkred]
> > >
> > > BTW, all the objects need to be new(ed) on the dims.
> > >
> > > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > > news:%23Q$CSNYdEHA.1048@tk2msftngp13.phx.gbl...
> > > > Something like this:
> > > >
> > > > Dim mydbConnection As OleDb.OleDbConnection
> > > > mydbConnection.ConnectionString = "c:\mydb.mdb"
> > > > mydbConnection.Open()
> > > >
> > > > Dim mydbCommand As OleDb.OleDbCommand
> > > > mydbCommand.Connection = mydbConnection
> > > > mydbCommand.CommandText = "SELECT * FROM MyTable"
> > > >
> > > > Dim myreader As oleDB.OleDbDataReader
> > > >
> > > > myreader = mydbCommand.ExecuteReader
> > > >
> > > > You can now inspect the myreader object the same way as you did with[/color]
> > your[color=darkred]
> > > > recordset.
> > > >
> > > > "Chris" <xcmharb@lineone.net> wrote in message
> > > > news:e5K2avXdEHA.2408@tk2msftngp13.phx.gbl...
> > > > > Can you give a code example that does teh same as my code below[/color]
> > please.[color=darkred]
> > > > >
> > > > >
> > > > > "Nick Wilton" <nickDOTwiltonAThtzDOTbiz> wrote in message
> > > > > news:%23KfkosXdEHA.3728@TK2MSFTNGP09.phx.gbl...
> > > > > > Use the OleDdDataAdapter, Connection and Command controls in[/color]
> > winforms[color=darkred]
> > > > to
> > > > > > generate the strings that you require for your app. To[/color][/color][/color]
manipulate[color=blue][color=green][color=darkred]
> > > these
> > > > > > strings programmatically try using the stringbuilder class.
> > > > > >
> > > > > > "Chris" <xcmharb@lineone.net> wrote in message
> > > > > > news:OSNebhXdEHA.1692@tk2msftngp13.phx.gbl...
> > > > > > > Hi all,
> > > > > > >
> > > > > > > I wrote a cool little database program a while back, in VB6,[/color][/color][/color]
and[color=blue][color=green]
> > im[color=darkred]
> > > > > > > intending to rewrite it in .net.
> > > > > > >
> > > > > > > I am new(ish) to .net, but an old hand at VB5/6.
> > > > > > >
> > > > > > > In VB i would access the mdb file something like this.
> > > > > > >
> > > > > > > set db=database
> > > > > > > set db=opendatabase("mydb.mdb")
> > > > > > > dim rec as recordset
> > > > > > > set rec= db.openrecordset("select name form names")
> > > > > > >
> > > > > > > while rec.eof=false
> > > > > > > debug.write(rec!name)
> > > > > rec.movenext
> > > > > > > wend
> > > > > > >
> > > > > > >
> > > > > > > How do i do the same in .net, it seems to want me to set up[/color][/color]
> these[color=green][color=darkred]
> > > > pages
> > > > > > ets,
> > > > > > > but i need to create queries and joins on the fly so data can[/color][/color][/color]
be[color=blue][color=green][color=darkred]
> > > > > accessed
> > > > > > as
> > > > > > > the user requests.
> > > > > > >
> > > > > > > Ive looked in the help, and followed the tutorials, but i cant[/color]
> > seem[color=darkred]
> > > to
> > > > > be
> > > > > > > able to query the db properly, or even connect to it in the[/color][/color][/color]
way[color=blue][color=green]
> > that[color=darkred]
> > > i
> > > > > > want.
> > > > > > >
> > > > > > > Thanks in advance
> > > > > > >
> > > > > > > Chris
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Connecting to a DataBase like i did in VB 6
Chris,
I am really stumbled, I made a sample exactly as yours however now in VBNet
way and you even did not look to it.
Cor |  | Similar .NET Framework bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,366 network members.
|