473,464 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

refer to a form's text box.text inside a SQL clause

How can i refer to a form's textbox.text inside a SQL clause ?

I know how is that in Access* but at VB i receive error.

* SELECT FIELD1 FROM TABLE1
WHERE TABLE1.FIELD2=[FORMS]![TEXTBOX].[NAME]
Feb 16 '07 #1
11 3740
On 16 Feb, 15:03, "giannis" <zzzinob...@freemail.grwrote:
How can i refer to a form's textbox.text inside a SQL clause ?

I know how is that in Access* but at VB i receive error.

* SELECT FIELD1 FROM TABLE1
WHERE TABLE1.FIELD2=[FORMS]![TEXTBOX].[NAME]

Hi Giannis try this

Dim strwhereclause as string =textbox1.text

SELECT FIELD1 FROM TABLE1 WHERE TABLE1.FIELD2= " ' " + strwhereclause
+" ' "

OR

SELECT FIELD1 FROM TABLE1 WHERE TABLE1.FIELD2= " ' " + textbox1.text
+" ' "

Thanks

Adam

Feb 16 '07 #2
Adamz5 wrote:
SELECT FIELD1 FROM TABLE1 WHERE TABLE1.FIELD2= " ' " + textbox1.text
+" ' "
The query builder change the textbox1.text in textbox1.[text] and thereby
i receive error.
Feb 16 '07 #3
You could use String.Format as done in the example code which can easily be
modified to suit your needs

Using command As New OleDbCommand(string.Format("SELECT * from customers
where = {0}",TextBox1.Text), connection)

"giannis" <zz********@freemail.grwrote in message
news:eY**************@TK2MSFTNGP06.phx.gbl...
How can i refer to a form's textbox.text inside a SQL clause ?

I know how is that in Access* but at VB i receive error.

* SELECT FIELD1 FROM TABLE1
WHERE TABLE1.FIELD2=[FORMS]![TEXTBOX].[NAME]

Feb 16 '07 #4
You're using a query builder in Visual Studio? For what, a strongly typed
dataset, or for setting up a stored procedure? You need to write your query
to take a parameter, and then when you execute it, pass in the string from
the textbox as the parameter.

Robin S.
---------------------------------
"giannis" <zz********@freemail.grwrote in message
news:uv**************@TK2MSFTNGP02.phx.gbl...
Adamz5 wrote:
>SELECT FIELD1 FROM TABLE1 WHERE TABLE1.FIELD2= " ' " + textbox1.text
+" ' "
The query builder change the textbox1.text in textbox1.[text] and thereby
i receive error.


Feb 16 '07 #5
Slight change, left out the field before the equal sign

Using command As New OleDbCommand(string.Format("SELECT * from customers
where SomeField = {0}",TextBox1.Text), connection)

"Kevin S Gallagher" <ke***************@state.or.uswrote in message
news:uh**************@TK2MSFTNGP03.phx.gbl...
You could use String.Format as done in the example code which can easily
be modified to suit your needs

Using command As New OleDbCommand(string.Format("SELECT * from customers
where = {0}",TextBox1.Text), connection)

"giannis" <zz********@freemail.grwrote in message
news:eY**************@TK2MSFTNGP06.phx.gbl...
>How can i refer to a form's textbox.text inside a SQL clause ?

I know how is that in Access* but at VB i receive error.

* SELECT FIELD1 FROM TABLE1
WHERE TABLE1.FIELD2=[FORMS]![TEXTBOX].[NAME]


Feb 16 '07 #6
Dim connection As New OleDbConnection(connectionString)

What must i write as connectionString in this example ?
I use a .mdb Access database.
Feb 16 '07 #7
go to your desktop

right-click NEW file = text.
change the file name to test.udl

double click on it; browse to your MDB.. hit apply save.

change the extension from UDL back to text; open with notepad
this will help you to build ANY connection string you ever need. and
it's built into windows


On Feb 16, 9:01 am, "giannis" <zzzinob...@freemail.grwrote:
Dim connection As New OleDbConnection(connectionString)

What must i write as connectionString in this example ?
I use a .mdb Access database.

Feb 16 '07 #8
I receive the :
Provider=MSDASQL.1;Persist Security Info=False;
Data Source=MS Access Database;Initial Catalog=c:\my.mdb

is this correct ?

The :
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=c:\my.mdb

is wrong ?
Feb 17 '07 #9
Did you try it?

A good place to look for help with connection strings is
http://www.connectionstrings.com
Robin S.
---------------------------
"giannis" <zz********@freemail.grwrote in message
news:O4**************@TK2MSFTNGP06.phx.gbl...
>I receive the :
Provider=MSDASQL.1;Persist Security Info=False;
Data Source=MS Access Database;Initial Catalog=c:\my.mdb

is this correct ?

The :
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=c:\my.mdb

is wrong ?

Feb 17 '07 #10
dude if the path to your MDB file is wrong; of course you have to
change that path.

Are you an adult???


On Feb 16, 10:24 pm, "giannis" <zzzinob...@freemail.grwrote:
I receive the :
Provider=MSDASQL.1;Persist Security Info=False;
Data Source=MS Access Database;Initial Catalog=c:\my.mdb

is this correct ?

The :
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=c:\my.mdb

is wrong ?

Feb 19 '07 #11
Technically, I provided a solution that will help to build 'any
connection string ever without going to the internet'

lose the training wheels, Robin


On Feb 16, 10:37 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Did you try it?

A good place to look for help with connection strings ishttp://www.connectionstrings.com

Robin S.
---------------------------"giannis" <zzzinob...@freemail.grwrote in message

news:O4**************@TK2MSFTNGP06.phx.gbl...
I receive the :
Provider=MSDASQL.1;Persist Security Info=False;
Data Source=MS Access Database;Initial Catalog=c:\my.mdb
is this correct ?
The :
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=c:\my.mdb
is wrong ?- Hide quoted text -

- Show quoted text -

Feb 19 '07 #12

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

Similar topics

8
by: William Bradley | last post by:
Following is the code I am using, behind a command button, on a form to print out only the report of that particular form. ******************** Code Start ************************ Dim strDocName...
3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
2
by: Seth Delaney | last post by:
I have a form with multiple unbound text boxes which serves as a "search form". I can enter my search parameters in the various boxes as needed and click okay. My records are then filtered to...
3
by: dskillingstad | last post by:
I'd appreciate any help I can get. I'm not sure what I'm doing wrong, but.... I've searched these groups for some solutions but no luck. I have an unbound form (frmSearch), with several unbound...
6
by: Jess | last post by:
hi, I am doing a windows application. I have this basic problem: I have a class Form1 got a label from another class B i want to display some text in the label in form 1 in class B, the...
1
by: Paul | last post by:
I have a MDI container form "frmParent". On that form there is a tabstrip control with 2 pages. On one of those pages there is a textbox and a button. When the user clicks on the button a...
3
by: JAPSTER | last post by:
An application has a startup form (Form1). A second form (frm2), created from within Form1. Each form has a textbox. To access the text in TextBox1 in frm2 from Form1, you use: ...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
6
by: Savante | last post by:
I have been writing a datalogging application. It reads in double's into a database. I want to be able to click on a row in a database (holds name of variable and also current value of variable)...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
1
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.