473,801 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3045
do you mean create a stored procedure?
Dim conn As New SqlConnection(m yConnectionStri ng)
conn.Open()
Dim cmd As SqlCommand = conn.CreateComm and()
cmd.CommandText = "CREATE PROCEDURE myNewStoredProc edure AS select * from
mytable"
cmd.ExecuteNonQ uery()
conn.Close()
Hope this helps

Dominique

"Wim" <wi***********@ pandora.be> wrote in message
news:fB******** ************@ph obos.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(c onnString)
Dim myCommand As New SqlCommand("sel ect count(*) from tblMessages", Conn)
myCommand.Conne ction.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******** ************@ph obos.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\Acce ss\2003.mdb"

"Wim" <wi***********@ pandora.be> schreef in bericht
news:fB******** ************@ph obos.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.Ole Db
dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateComm and()
cmd.CommandText = "insert into mytable (columnname) values ('the query...')"
cmd.ExecuteNonQ uery()
conn.Close()
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:6_******** *************@p hobos.telenet-ops.be...
the access database is located at
"C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"

"Wim" <wi***********@ pandora.be> schreef in bericht
news:fB******** ************@ph obos.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_inser t@tralala_tenfo rce.com> schreef in
bericht news:Oq******** ******@TK2MSFTN GP11.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.Ole Db
dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateComm and()
cmd.CommandText = "insert into mytable (columnname) values ('the query...')" cmd.ExecuteNonQ uery()
conn.Close()
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:6_******** *************@p hobos.telenet-ops.be...
the access database is located at
"C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"

"Wim" <wi***********@ pandora.be> schreef in bericht
news:fB******** ************@ph obos.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=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateComm and()
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:Ie******** *************@p hobos.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_inser t@tralala_tenfo rce.com> schreef in
bericht news:Oq******** ******@TK2MSFTN GP11.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.Ole Db
dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateComm and()
cmd.CommandText = "insert into mytable (columnname) values ('the

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

"Wim" <wi***********@ pandora.be> schreef in bericht
news:fB******** ************@ph obos.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_inser t@tralala_tenfo rce.com> schreef in
bericht news:ud******** *****@TK2MSFTNG P11.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=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateComm and()
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:Ie******** *************@p hobos.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_inser t@tralala_tenfo rce.com> schreef in
bericht news:Oq******** ******@TK2MSFTN GP11.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.Ole Db
dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As SqlCommand = conn.CreateComm and()
cmd.CommandText = "insert into mytable (columnname) values ('the

query...')"
cmd.ExecuteNonQ uery()
conn.Close()
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:6_******** *************@p hobos.telenet-ops.be...
> the access database is located at
> "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
>
> "Wim" <wi***********@ pandora.be> schreef in bericht
> news:fB******** ************@ph obos.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.Ol eDb.OleDbExcept ion' occurred in system.data.dll " at
conn.open()

what can i do?

Regards,

wim

Imports System.Data.Ole Db

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.

InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() 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.Disp ose()

End If

End If

MyBase.Dispose( disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'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.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

'

'Form1

'

Me.AutoScaleBas eSize = 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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

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

conn.Open()

Dim cmd As OleDbCommand = conn.CreateComm and()

cmd.CommandType = CommandType.Sto redProcedure

cmd.CommandText = "select * from import"

End Sub

End Class

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

wim
"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
bericht news:ud******** *****@TK2MSFTNG P11.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=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
conn.Open()
Dim cmd As OleDbCommand = conn.CreateComm and()
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "myquery"
Dominique
"Wim" <wi***********@ pandora.be> wrote in message
news:Ie******** *************@p hobos.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_inser t@tralala_tenfo rce.com> schreef in bericht news:Oq******** ******@TK2MSFTN GP11.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.Ole Db
>
>
> dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
> conn.Open()
> Dim cmd As SqlCommand = conn.CreateComm and()
> cmd.CommandText = "insert into mytable (columnname) values ('the
query...')"
> cmd.ExecuteNonQ uery()
> conn.Close()
>
>
> Dominique
>
>
> "Wim" <wi***********@ pandora.be> wrote in message
> news:6_******** *************@p hobos.telenet-ops.be...
> > the access database is located at
> > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
> >
> > "Wim" <wi***********@ pandora.be> schreef in bericht
> > news:fB******** ************@ph obos.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

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

Similar topics

2
3435
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 new values are updated in all corresponding tables (the function of the pages in question). However, on the page that does the DB update, I also want to do some checks on the data before performing the update. Now, the problem that I am...
3
1957
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
5659
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. Simply, I'm including one calcualtion from a separate table/query. It sums the total units sold to date by ProductID number and is used in other select queries to perform various calculations. Perhaps there is an advantage in working with a maximum...
7
3540
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 performs MySQL queries to a database. These queries are performed at regular intervals. Basically it is looking for fields that match certain criterias. Such fields are not present at all time. When the program finds such field, it then takes
13
2871
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 other than a select query using the Wizard? What do you think happened to her data? I am working remotely until Friday, so I can't get down to her office and check out what she did.
1
3601
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 between postgres database and C application(which we have written for accessing the database) ? My code is comiling successfully if i run it then its giving o/p as following : output
2
4531
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, withonly the record(s) meeting the criteria being returned to the front end? Is JetShowPlan a good tool to see that this is working? Bob
3
7775
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 appears. It doesn't happen every time, and using the Zoom window works fine. It appears that it only happens when I want to modify an existing expression. This continues to happen even after the database is repaired and reopened. Anyone have any...
32
2684
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 trying to create a database for work, using Microsoft Access 2003 on Windows XP. I have a product licensing database and it has one table named serial numbers, that table holds all the information associated with SNs, including customer name,...
2
9846
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 to open in datasheet view. As an experiment, I deleted all rows in all tables; after that, the query took only seconds to open in both design view and datasheet view. From these facts, I conclude that Access is evaluating the query when I go to...
0
9697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9555
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10515
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10291
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9100
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3771
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.