By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

BD with access y reference your fields

P: n/a
hello,
I have a problem to a database (Access) and I reference its fields
before in Vb 6, I am do this with:

Dim RS As Recordset
Nombre_BD = "SERVICIOS.MDB"
Set ConexionBD = OpenDatabase(App.Path & "\" & Nombre_BD)
Set RS = ConexionBD.OpenRecordset("Select * from tabla")
RS.Fields("companyiaParte")

In visual basic .net, what am I do??

Thanks
nahald

Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi Nahald,

Something as this
\\\
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\SERVICIOS.MDB;" )
Try
Dim cmd As New OleDbCommand("Select * from tabla", Conn)
da = New OleDbDataAdapter(cmd)
da.Fill(ds, "tabla")
Catch oledbExc As OleDbException
MessageBox.Show(oledbExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
The item from the first row is
dim a as string = ds.tables("tabla").rows(0).item("companyiaParte"). tostring
///

I hope this was what you where looking for?

Cor

hello,
I have a problem to a database (Access) and I reference its fields
before in Vb 6, I am do this with:

Dim RS As Recordset
Nombre_BD = "SERVICIOS.MDB"
Set ConexionBD = OpenDatabase(App.Path & "\" & Nombre_BD)
Set RS = ConexionBD.OpenRecordset("Select * from tabla")
RS.Fields("companyiaParte")

In visual basic .net, what am I do??

Nov 20 '05 #2

P: n/a
Sorry, but You don´t defined ds than a variable, What is "ds"?

"Cor" <no*@non.com> escribió en el mensaje
news:OK**************@tk2msftngp13.phx.gbl...
Hi Nahald,

Something as this
\\\
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=C:\SERVICIOS.MDB;" )
Try
Dim cmd As New OleDbCommand("Select * from tabla", Conn)
da = New OleDbDataAdapter(cmd)
da.Fill(ds, "tabla")
Catch oledbExc As OleDbException
MessageBox.Show(oledbExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
The item from the first row is
dim a as string = ds.tables("tabla").rows(0).item("companyiaParte"). tostring ///

I hope this was what you where looking for?

Cor

hello,
I have a problem to a database (Access) and I reference its fields
before in Vb 6, I am do this with:

Dim RS As Recordset
Nombre_BD = "SERVICIOS.MDB"
Set ConexionBD = OpenDatabase(App.Path & "\" & Nombre_BD)
Set RS = ConexionBD.OpenRecordset("Select * from tabla")
RS.Fields("companyiaParte")

In visual basic .net, what am I do??


Nov 20 '05 #3

P: n/a
Cor
Hi Nahald,

Good you showed me I forgot that row

Now it is between the text

Sorry.

Cor
Sorry, but You don´t defined ds than a variable, What is "ds"?

Something as this
\\\
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " &

"Data
Source=C:\SERVICIOS.MDB;" )
Try
Dim cmd As New OleDbCommand("Select * from tabla", Conn)
dim ds as new Dataset
da = New OleDbDataAdapter(cmd)
da.Fill(ds, "tabla")
Catch oledbExc As OleDbException
MessageBox.Show(oledbExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
The item from the first row is
dim a as string =

ds.tables("tabla").rows(0).item("companyiaParte"). tostring
///

I hope this was what you where looking for?

Cor

hello,
I have a problem to a database (Access) and I reference its fields
before in Vb 6, I am do this with:

Dim RS As Recordset
Nombre_BD = "SERVICIOS.MDB"
Set ConexionBD = OpenDatabase(App.Path & "\" & Nombre_BD)
Set RS = ConexionBD.OpenRecordset("Select * from tabla")
RS.Fields("companyiaParte")

In visual basic .net, what am I do??



Nov 20 '05 #4

P: n/a
ok, thanks I think this line.
If I have to do a insert, update o delete in database, I will change this
line:

Dim cmd As New OleDbCommand("Select * from tabla", Conn)

Is this true?

nahald

"Cor" <no*@non.com> escribió en el mensaje
news:Oz**************@TK2MSFTNGP12.phx.gbl...
Hi Nahald,

Good you showed me I forgot that row

Now it is between the text

Sorry.

Cor
Sorry, but You don´t defined ds than a variable, What is "ds"?

Something as this
\\\
Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " &

"Data
Source=C:\SERVICIOS.MDB;" )
Try
Dim cmd As New OleDbCommand("Select * from tabla", Conn)
dim ds as new Dataset
da = New OleDbDataAdapter(cmd)
da.Fill(ds, "tabla")
Catch oledbExc As OleDbException
MessageBox.Show(oledbExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
The item from the first row is
dim a as string =

ds.tables("tabla").rows(0).item("companyiaParte"). tostring
///

I hope this was what you where looking for?

Cor
> hello,
> I have a problem to a database (Access) and I reference its fields
> before in Vb 6, I am do this with:
>
> Dim RS As Recordset
> Nombre_BD = "SERVICIOS.MDB"
> Set ConexionBD = OpenDatabase(App.Path & "\" & Nombre_BD)
> Set RS = ConexionBD.OpenRecordset("Select * from tabla")
> RS.Fields("companyiaParte")
>
> In visual basic .net, what am I do??
>



Nov 20 '05 #5

P: n/a
Cor
Nahald,

Yes and than add them to the dataAdapter with
da.DeleteCommand = cmd (to do for the insertcommand, the deletecommand and
the updatecommand)

But for an update for a select as you are using it is more simple to add
after the
da = New OleDbDataAdapter(cmd) Dim cb As New OleDbCommandBuilder(da)
(that makes and add the update, delete and insert for you, but they said it
is buggy with a lot of parameters).

When you have done that you can do to update
\\\
if ds.haschanges
da.update(ds.getchanges)
end if
///

Cor
ok, thanks I think this line.
If I have to do a insert, update o delete in database, I will change this
line:

Dim cmd As New OleDbCommand("Select * from tabla", Conn)

Is this true?

nahald

> \\\
> Dim Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
> Source=C:\SERVICIOS.MDB;" )
> Try
> Dim cmd As New OleDbCommand("Select * from tabla", Conn)


dim ds as new Dataset
> > > > > da.Fill(ds, "tabla")
> Catch oledbExc As OleDbException
> MessageBox.Show(oledbExc.ToString)
> Catch ex As Exception
> MessageBox.Show(ex.Message)
> Finally
> Conn.Close()
> End Try
> The item from the first row is
> dim a as string =
ds.tables("tabla").rows(0).item("companyiaParte"). tostring
> ///
>

Nov 20 '05 #6

P: n/a
Thanks for all
I will test this.
nahald

"Cor" <no*@non.com> escribió en el mensaje
news:OR**************@TK2MSFTNGP11.phx.gbl...
Nahald,

Yes and than add them to the dataAdapter with
da.DeleteCommand = cmd (to do for the insertcommand, the deletecommand and the updatecommand)

But for an update for a select as you are using it is more simple to add
after the
da = New OleDbDataAdapter(cmd) Dim cb As New OleDbCommandBuilder(da)
(that makes and add the update, delete and insert for you, but they said it is buggy with a lot of parameters).

When you have done that you can do to update
\\\
if ds.haschanges
da.update(ds.getchanges)
end if
///

Cor
ok, thanks I think this line.
If I have to do a insert, update o delete in database, I will change this line:

Dim cmd As New OleDbCommand("Select * from tabla", Conn)

Is this true?

nahald
> \\\
> > Dim Conn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & > "Data
> > Source=C:\SERVICIOS.MDB;" )
> > Try
> > Dim cmd As New OleDbCommand("Select * from tabla", Conn)

dim ds as new Dataset

> > > > > > da.Fill(ds, "tabla")
> > Catch oledbExc As OleDbException
> > MessageBox.Show(oledbExc.ToString)
> > Catch ex As Exception
> > MessageBox.Show(ex.Message)
> > Finally
> > Conn.Close()
> > End Try
> > The item from the first row is
> > dim a as string =
> ds.tables("tabla").rows(0).item("companyiaParte"). tostring
> > ///
> >


Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.