473,386 Members | 1,801 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,386 software developers and data experts.

How to put query in database?

Wim
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim
Nov 20 '05 #1
18 3013
do you mean create a stored procedure?
Dim conn As New SqlConnection(myConnectionString)
conn.Open()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "CREATE PROCEDURE myNewStoredProcedure AS select * from
mytable"
cmd.ExecuteNonQuery()
conn.Close()
Hope this helps

Dominique

"Wim" <wi***********@pandora.be> wrote in message
news:fB********************@phobos.telenet-ops.be...
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim

Nov 20 '05 #2
Cor
Hi Wim,

Something as this
\\\
Dim Conn As New SqlConnection(connString)
Dim myCommand As New SqlCommand("select count(*) from tblMessages", Conn)
myCommand.Connection.Open()
Dim count As Integer = CInt(myCommand.ExecuteScalar())
Conn.Close()
///

I hope this helps?

Cor
Nov 20 '05 #3
Wim
Hi Cor and Dominique,

I just need to make a new query and save this in an access database....

Is your code doing this?

Regards,

wim
"Wim" <wi***********@pandora.be> schreef in bericht
news:fB********************@phobos.telenet-ops.be...
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim

Nov 20 '05 #4
Wim
the access database is located at
"C:\backup Compaq MV500\TAGS\Access\2003.mdb"

"Wim" <wi***********@pandora.be> schreef in bericht
news:fB********************@phobos.telenet-ops.be...
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim

Nov 20 '05 #5
do you want to put your query as data in a table?
if so see code
if put it in access as a stored procedure then no can do...

Imports System.Data.OleDb
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "insert into mytable (columnname) values ('the query...')"
cmd.ExecuteNonQuery()
conn.Close()
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:6_*********************@phobos.telenet-ops.be...
the access database is located at
"C:\backup Compaq MV500\TAGS\Access\2003.mdb"

"Wim" <wi***********@pandora.be> schreef in bericht
news:fB********************@phobos.telenet-ops.be...
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim


Nov 20 '05 #6
Wim
No I don't want to put data in the table...

only put a new query in the access database and use it later..

So you think this is impossible??

Regards

wim

ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
do you want to put your query as data in a table?
if so see code
if put it in access as a stored procedure then no can do...

Imports System.Data.OleDb
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "insert into mytable (columnname) values ('the query...')" cmd.ExecuteNonQuery()
conn.Close()
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:6_*********************@phobos.telenet-ops.be...
the access database is located at
"C:\backup Compaq MV500\TAGS\Access\2003.mdb"

"Wim" <wi***********@pandora.be> schreef in bericht
news:fB********************@phobos.telenet-ops.be...
Hi,

I would like to make and put a query in my database by VB.NET code.

Is this possible?

Thanks for your help,

wim



Nov 20 '05 #7
you can do something alike stored procedures with access (queries)
but I don't know if you can create them from vb.net code

to call them:

dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:Ie*********************@phobos.telenet-ops.be...
No I don't want to put data in the table...

only put a new query in the access database and use it later..

So you think this is impossible??

Regards

wim

ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
do you want to put your query as data in a table?
if so see code
if put it in access as a stored procedure then no can do...

Imports System.Data.OleDb
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "insert into mytable (columnname) values ('the

query...')"
cmd.ExecuteNonQuery()
conn.Close()
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:6_*********************@phobos.telenet-ops.be...
the access database is located at
"C:\backup Compaq MV500\TAGS\Access\2003.mdb"

"Wim" <wi***********@pandora.be> schreef in bericht
news:fB********************@phobos.telenet-ops.be...
> Hi,
>
> I would like to make and put a query in my database by VB.NET code.
>
> Is this possible?
>
> Thanks for your help,
>
> wim
>
>



Nov 20 '05 #8
Wim
ok ,thanks a lot

wim
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:ud*************@TK2MSFTNGP11.phx.gbl...
you can do something alike stored procedures with access (queries)
but I don't know if you can create them from vb.net code

to call them:

dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:Ie*********************@phobos.telenet-ops.be...
No I don't want to put data in the table...

only put a new query in the access database and use it later..

So you think this is impossible??

Regards

wim

ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
do you want to put your query as data in a table?
if so see code
if put it in access as a stored procedure then no can do...

Imports System.Data.OleDb
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "insert into mytable (columnname) values ('the

query...')"
cmd.ExecuteNonQuery()
conn.Close()
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:6_*********************@phobos.telenet-ops.be...
> the access database is located at
> "C:\backup Compaq MV500\TAGS\Access\2003.mdb"
>
> "Wim" <wi***********@pandora.be> schreef in bericht
> news:fB********************@phobos.telenet-ops.be...
> > Hi,
> >
> > I would like to make and put a query in my database by VB.NET code. > >
> > Is this possible?
> >
> > Thanks for your help,
> >
> > wim
> >
> >
>
>



Nov 20 '05 #9
Wim
Hi Dominique,

I get error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" at
conn.open()

what can i do?

Regards,

wim

Imports System.Data.OleDb

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Name = "Form1"

Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim conn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\backup
Compaq MV500\TAGS\Access\2003.mdb")

conn.Open()

Dim cmd As OleDbCommand = conn.CreateCommand()

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "select * from import"

End Sub

End Class

"Wim" <wi***********@pandora.be> schreef in bericht
news:oO*********************@phobos.telenet-ops.be...
ok ,thanks a lot

wim
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:ud*************@TK2MSFTNGP11.phx.gbl...
you can do something alike stored procedures with access (queries)
but I don't know if you can create them from vb.net code

to call them:

dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:Ie*********************@phobos.telenet-ops.be...
No I don't want to put data in the table...

only put a new query in the access database and use it later..

So you think this is impossible??

Regards

wim

ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
> do you want to put your query as data in a table?
> if so see code
> if put it in access as a stored procedure then no can do...
>
>
>
> Imports System.Data.OleDb
>
>
> dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data > Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
> conn.Open()
> Dim cmd As SqlCommand = conn.CreateCommand()
> cmd.CommandText = "insert into mytable (columnname) values ('the
query...')"
> cmd.ExecuteNonQuery()
> conn.Close()
>
>
> Dominique
>
>
> "Wim" <wi***********@pandora.be> wrote in message
> news:6_*********************@phobos.telenet-ops.be...
> > the access database is located at
> > "C:\backup Compaq MV500\TAGS\Access\2003.mdb"
> >
> > "Wim" <wi***********@pandora.be> schreef in bericht
> > news:fB********************@phobos.telenet-ops.be...
> > > Hi,
> > >
> > > I would like to make and put a query in my database by VB.NET code. > > >
> > > Is this possible?
> > >
> > > Thanks for your help,
> > >
> > > wim
> > >
> > >
> >
> >
>
>



Nov 20 '05 #10
9 out of 10 your db is in use :-)

do a try/catch and check the exception message and stacktrace for more
info...
hope this helps

dominique

"Wim" <wi***********@pandora.be> wrote in message
news:DP*********************@phobos.telenet-ops.be...
Hi Dominique,

I get error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" at
conn.open()

what can i do?

Regards,

wim

Imports System.Data.OleDb

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Name = "Form1"

Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim conn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\backup
Compaq MV500\TAGS\Access\2003.mdb")

conn.Open()

Dim cmd As OleDbCommand = conn.CreateCommand()

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "select * from import"

End Sub

End Class

"Wim" <wi***********@pandora.be> schreef in bericht
news:oO*********************@phobos.telenet-ops.be...
ok ,thanks a lot

wim
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:ud*************@TK2MSFTNGP11.phx.gbl...
you can do something alike stored procedures with access (queries)
but I don't know if you can create them from vb.net code

to call them:

dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@pandora.be> wrote in message
news:Ie*********************@phobos.telenet-ops.be...
> No I don't want to put data in the table...
>
> only put a new query in the access database and use it later..
>
> So you think this is impossible??
>
> Regards
>
> wim
>
>
>
> ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef

in > bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
> > do you want to put your query as data in a table?
> > if so see code
> > if put it in access as a stored procedure then no can do...
> >
> >
> >
> > Imports System.Data.OleDb
> >
> >
> > dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data > > Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
> > conn.Open()
> > Dim cmd As SqlCommand = conn.CreateCommand()
> > cmd.CommandText = "insert into mytable (columnname) values ('the
> query...')"
> > cmd.ExecuteNonQuery()
> > conn.Close()
> >
> >
> > Dominique
> >
> >
> > "Wim" <wi***********@pandora.be> wrote in message
> > news:6_*********************@phobos.telenet-ops.be...
> > > the access database is located at
> > > "C:\backup Compaq MV500\TAGS\Access\2003.mdb"
> > >
> > > "Wim" <wi***********@pandora.be> schreef in bericht
> > > news:fB********************@phobos.telenet-ops.be...
> > > > Hi,
> > > >
> > > > I would like to make and put a query in my database by VB.NET

code.
> > > >
> > > > Is this possible?
> > > >
> > > > Thanks for your help,
> > > >
> > > > wim
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #11
Wim

Hi Dominique,

I tried and got this errors :

Kan het installeerbare ISAM-bestand niet vinden.
at System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvid er()
at System.Data.OleDb.OleDbConnection.Open()
at make_query_20_jan_2004.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Documents and Settings\Eigenaar\Mijn documenten\Visual Studio
Projects\make query 20 jan 2004\Form1.vb:line 63

Any idea?

regards,

Wim

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim conn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\backup
Compaq MV500\TAGS\Access\2003.mdb")

Try

conn.Open()

Catch ex As Exception

TextBox1.Text = (ex.Message)

TextBox1.Text = TextBox1.Text & (ex.StackTrace)

'conn.Close()

End Try

Dim cmd As OleDbCommand = conn.CreateCommand()

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "select * from import"

End Sub

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in
bericht news:OI**************@TK2MSFTNGP12.phx.gbl...
9 out of 10 your db is in use :-)

do a try/catch and check the exception message and stacktrace for more
info...
hope this helps

dominique

"Wim" <wi***********@pandora.be> wrote in message
news:DP*********************@phobos.telenet-ops.be...
Hi Dominique,

I get error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" at
conn.open()

what can i do?

Regards,

wim

Imports System.Data.OleDb

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Name = "Form1"

Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim conn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\backup
Compaq MV500\TAGS\Access\2003.mdb")

conn.Open()

Dim cmd As OleDbCommand = conn.CreateCommand()

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "select * from import"

End Sub

End Class

"Wim" <wi***********@pandora.be> schreef in bericht
news:oO*********************@phobos.telenet-ops.be...
ok ,thanks a lot

wim
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef in bericht news:ud*************@TK2MSFTNGP11.phx.gbl...
> you can do something alike stored procedures with access (queries)
> but I don't know if you can create them from vb.net code
>
> to call them:
>
> dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data > Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
> conn.Open()
> Dim cmd As OleDbCommand = conn.CreateCommand()
> cmd.CommandType = CommandType.StoredProcedure
> cmd.CommandText = "myquery"
>
>
> Dominique
>
>
> "Wim" <wi***********@pandora.be> wrote in message
> news:Ie*********************@phobos.telenet-ops.be...
> > No I don't want to put data in the table...
> >
> > only put a new query in the access database and use it later..
> >
> > So you think this is impossible??
> >
> > Regards
> >
> > wim
> >
> >
> >
> > ominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> schreef
in
> > bericht news:Oq**************@TK2MSFTNGP11.phx.gbl...
> > > do you want to put your query as data in a table?
> > > if so see code
> > > if put it in access as a stored procedure then no can do...
> > >
> > >
> > >
> > > Imports System.Data.OleDb
> > >
> > >
> > > dim conn as New

OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
> > > Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
> > > conn.Open()
> > > Dim cmd As SqlCommand = conn.CreateCommand()
> > > cmd.CommandText = "insert into mytable (columnname) values ('the
> > query...')"
> > > cmd.ExecuteNonQuery()
> > > conn.Close()
> > >
> > >
> > > Dominique
> > >
> > >
> > > "Wim" <wi***********@pandora.be> wrote in message
> > > news:6_*********************@phobos.telenet-ops.be...
> > > > the access database is located at
> > > > "C:\backup Compaq MV500\TAGS\Access\2003.mdb"
> > > >
> > > > "Wim" <wi***********@pandora.be> schreef in bericht
> > > > news:fB********************@phobos.telenet-ops.be...
> > > > > Hi,
> > > > >
> > > > > I would like to make and put a query in my database by

VB.NET code.
> > > > >
> > > > > Is this possible?
> > > > >
> > > > > Thanks for your help,
> > > > >
> > > > > wim
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #12
Cor
Hi Wim,

What is on line 63 it gives me a little bit the idea that you did make a
connection with the designer and that you try to overule that with a new
connection string. (I tried that once and that did work).

But it seems to me that you get an error on line 63 (because when you use
the designer and a form, that is at the beginning of the code).

Just an Idea.

Cor

Kan het installeerbare ISAM-bestand niet vinden.

Are you sure Domenique understand this?

:-)
Nov 20 '05 #13
Wim
Hi Cor,
How can I check if I made a connection with the designer?

ADO.NET and VB.NET It is new to me, so maybe I make basic mistake....

Thanks,

Wim
"Cor" <no*@non.com> schreef in bericht
news:%2***************@tk2msftngp13.phx.gbl...
Hi Wim,

What is on line 63 it gives me a little bit the idea that you did make a
connection with the designer and that you try to overule that with a new
connection string. (I tried that once and that did work).

But it seems to me that you get an error on line 63 (because when you use
the designer and a form, that is at the beginning of the code).

Just an Idea.

Cor

Kan het installeerbare ISAM-bestand niet vinden.

Are you sure Domenique understand this?

:-)

Nov 20 '05 #14
Wim
Cor,

In this other program I get also an error at conn.open

No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D).
at System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvid er()
at System.Data.OleDb.OleDbConnection.Open()
at database_20_jan_2004.Form1.btnDatabase_Click(Objec t sender, EventArgs
e) in C:\Documents and Settings\Eigenaar\Mijn documenten\Visual Studio
Projects\Laptop\database 20 jan 2004\Form1.vb:line 80

Private Sub btnDatabase_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDatabase.Click

Dim ds As New DataSet()

ds = New DataSet("import")

Dim Connectionstring As String

Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID=Admin;Data Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;Mode=Share
Deny None;Extended Properties="";Jet OLEDB:System database="";Jet
OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine
Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"

'Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID=Admin;Data Source=C:\TAGS\Access\2003.mdb;Mode=Share Deny None;Extended
Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System
Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale
on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False"

Dim connection1 As OleDb.OleDbConnection = New
OleDb.OleDbConnection(Connectionstring)

Dim command1 As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * from
import")

command1.CommandType = CommandType.Text

Try

connection1.Open()

Catch ex As Exception

txtError.Text = ex.Message & vbCrLf

txtError.Text = txtError.Text & ex.StackTrace

End Try

'command1.Connection = connection1

'Dim OleDbDataAdapter1 As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter()

'OleDbDataAdapter1.SelectCommand = command1

'OleDbDataAdapter1.TableMappings.Add("Table", "import")

'OleDbDataAdapter1.Fill(ds)

'Dim datagrid1 As New DataGrid()

'datagrid1.SetDataBinding(ds, "import")

End Sub

"Wim" <wi***********@pandora.be> schreef in bericht
news:JU********************@phobos.telenet-ops.be...
Hi Cor,
How can I check if I made a connection with the designer?

ADO.NET and VB.NET It is new to me, so maybe I make basic mistake....

Thanks,

Wim
"Cor" <no*@non.com> schreef in bericht
news:%2***************@tk2msftngp13.phx.gbl...
Hi Wim,

What is on line 63 it gives me a little bit the idea that you did make a
connection with the designer and that you try to overule that with a new
connection string. (I tried that once and that did work).

But it seems to me that you get an error on line 63 (because when you use the designer and a form, that is at the beginning of the code).

Just an Idea.

Cor

Kan het installeerbare ISAM-bestand niet vinden.

Are you sure Domenique understand this?

:-)


Nov 20 '05 #15
Cor
Hi Wim,

Can you only try this (I am not sure if it is direct the solution)
But than we can see it it connects.
Dim connection1 As OleDb.OleDbConnection = _ New OleDb.OleDbConnection(Connectionstring)
Dim command1 As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * from
import") -Delete rows above
command1.CommandType = CommandType.Text -Delete row above
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
Dim OleDbDataAdapter1 As OleDb.OleDbDataAdapter = _
New OleDb.OleDbDataAdapter("Select * from import",conn)
dim ds as new dataset
Try
OleDbDataAdapter1.Fill(ds)
connection1.Open() -Delete row above
Catch ex As Exception

txtError.Text = ex.Message & vbCrLf

txtError.Text = txtError.Text & ex.StackTrace

End Try

Nov 20 '05 #16
Wim
Hi Cor,

I tried this code and this didn't give any error's anymore......
Do you now what was wrong? the conn.open? or the OleDbCommand?
What to do to showthe dataset in Datagrid1 on the form?

thanks,

wim
Private Sub btnDatabase_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDatabase.Click

'ds = New DataSet("import")

'Dim Connectionstring As String

'Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User
ID=Admin;Data Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;Mode=Share
Deny None;Extended Properties="";Jet OLEDB:System database="";Jet
OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine
Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"

'Dim connection1 As OleDbConnection = New OleDbConnection(Connectionstring)

'Dim command1 As OleDbCommand = New OleDbCommand("Select * from import")

'command1.CommandType = CommandType.Text

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")

Dim oleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter("select *
from import", conn)

Dim ds As New DataSet()

Try

oledbdataadapter1.Fill(ds)

'conn.Open()

Catch ex As Exception

txtError.Text = ex.Message & vbCrLf

txtError.Text = txtError.Text & ex.StackTrace

End Try

'Try

' connection1.Open()

'Catch ex As Exception

' txtError.Text = ex.Message & vbCrLf

' txtError.Text = txtError.Text & ex.StackTrace

'End Try

'command1.Connection = connection1

'Dim OleDbDataAdapter1 As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter()

'OleDbDataAdapter1.SelectCommand = command1

'OleDbDataAdapter1.TableMappings.Add("Table", "import")

'OleDbDataAdapter1.Fill(ds)

'Dim datagrid1 As New DataGrid()

'DataGrid1.SetDataBinding(ds, "import")

End Sub
"Cor" <no*@non.com> schreef in bericht
news:e8**************@tk2msftngp13.phx.gbl...
Hi Wim,

Can you only try this (I am not sure if it is direct the solution)
But than we can see it it connects.
Dim connection1 As OleDb.OleDbConnection = _

New OleDb.OleDbConnection(Connectionstring)

Dim command1 As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * from import")

-Delete rows above
command1.CommandType = CommandType.Text

-Delete row above
dim conn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\backup Compaq MV500\TAGS\Access\2003.mdb;")
Dim OleDbDataAdapter1 As OleDb.OleDbDataAdapter = _
New OleDb.OleDbDataAdapter("Select * from import",conn)
dim ds as new dataset
Try
OleDbDataAdapter1.Fill(ds)

connection1.Open()

-Delete row above
Catch ex As Exception

txtError.Text = ex.Message & vbCrLf

txtError.Text = txtError.Text & ex.StackTrace

End Try


Nov 20 '05 #17
Cor
Hi Wim,

I asume it is a winforms datagrid than just
'OleDbDataAdapter1.Fill(ds)
'Dim datagrid1 As New DataGrid()
'DataGrid1.SetDataBinding(ds, "import")

Replace row above by
DataGrid1.datasource =ds.tables(0)

I hope this helps

Cor
Nov 20 '05 #18
Wim

hi Cor,

thanks this is working good!

Now I need to find out how to copy records from 1 table (table import) to
another table (table dummy) by a query.
The second table must be cleared each time before I run the query.....

The first table (import) has a field "time" and what I want is to select
only those records between time1 and time2.

If possible Time1 and Time2 are date variable that I can give a value by
dtaepicker or textbox ...
I'll buy second book special for ADO.NET because My VB.NET book learns me
little about it..
Thanks again for your help,

Wim


"Cor" <no*@non.com> schreef in bericht
news:OP**************@TK2MSFTNGP09.phx.gbl...
Hi Wim,

I asume it is a winforms datagrid than just
'OleDbDataAdapter1.Fill(ds)
'Dim datagrid1 As New DataGrid()
'DataGrid1.SetDataBinding(ds, "import")

Replace row above by
DataGrid1.datasource =ds.tables(0)

I hope this helps

Cor

Nov 20 '05 #19

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

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
1
by: Pradeep83 | last post by:
Hi All Problem : I am unable to retrieve the data from the table in postgres database using C application which i have written in solaris os. Query: How to check whether connection is there...
2
by: Bob Alston | last post by:
If you have an access form with record source being a straightforward query and where clause in the form definition, will the query be sent to the back end jet/Access database and executed there,...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
32
by: wexx | last post by:
I have been looking for some time now (reading books off Safari, searching through forums,etc) I have found no solution to this problem. I turn to anyone of you that may be able to help me. I'm...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
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,...
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: 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$) { } ...
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
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
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?
0
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 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.