Hello
I am using the MS Data Access Application Block in VB.NET, and I'm having no problems with my queries that call one table with no parameters
I can't figure out how to do the following
I want to pull data from 1 tables, with a variable as a parameter
The code I'm using (that isn't working) is
lBoxCP.DataSource = Nothin
lBoxCP.Items.Clear(
lBoxCP.Refresh(
Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT
Dim ConStr As String = "workstation id=LAPTOPAMBER;packet size=4096;integrated security=SSPI;initial catalog=fsAbitibi;persist security info=False
Dim dssCP As DataSet = SqlHelper.ExecuteDataset(ConStr, CommandType.Text,
"SELECT ID_CUTTING_PERMIT, STR_CUTTING_PERMIT, STR_FOREST_DISTRICT, STR_FOREST_REGION, STR_TSA, STR_LICENSEE, STR_LICENSE_NO, STR_OPERATING_AREA, STR_TIMBER_MARK, STR_CATEGORY, DTM_FORECAST, STR_EMPLOYEE, DTM_COMPLETE, STR_SIGN_OFF_BY, DTM_SIGN_OFF, STR_PEER_REVIEW, DTM_PEER_REVIEW, STR_SIGN_OFF_STATUS, STR_SIGN_OFF_COM FROM TDT_CUTTING_PERMIT WHERE STR_CUTTING_PERMIT = ", CI
lBoxCP.DataSource = dssCP.Tables(0
lBoxCP.DisplayMember = "STR_CUTTING_PERMIT
Does my problem lie with the Where clause?
Thanks in advance
Ambe 7 5808
I don't have a lot of experience with the data applicaiton block but your
sql statement in general is kinda weird..
You don't ever seem to assign a variable area (such as String.Format uses
like {0})
Even when you do... its always a true value... you might want to read up
more on the data appilcation block and how to do variables in the SqlHelper.
-CJ
"amber" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com... Hello, I am using the MS Data Access Application Block in VB.NET, and I'm having
no problems with my queries that call one table with no parameters. I can't figure out how to do the following: I want to pull data from 1 tables, with a variable as a parameter. The code I'm using (that isn't working) is:
lBoxCP.DataSource = Nothing lBoxCP.Items.Clear() lBoxCP.Refresh() Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT" Dim ConStr As String = "workstation id=LAPTOPAMBER;packet
size=4096;integrated security=SSPI;initial catalog=fsAbitibi;persist
security info=False" Dim dssCP As DataSet = SqlHelper.ExecuteDataset(ConStr,
CommandType.Text, _ "SELECT ID_CUTTING_PERMIT, STR_CUTTING_PERMIT,
STR_FOREST_DISTRICT, STR_FOREST_REGION, STR_TSA, STR_LICENSEE,
STR_LICENSE_NO, STR_OPERATING_AREA, STR_TIMBER_MARK, STR_CATEGORY,
DTM_FORECAST, STR_EMPLOYEE, DTM_COMPLETE, STR_SIGN_OFF_BY, DTM_SIGN_OFF,
STR_PEER_REVIEW, DTM_PEER_REVIEW, STR_SIGN_OFF_STATUS, STR_SIGN_OFF_COM FROM
TDT_CUTTING_PERMIT WHERE STR_CUTTING_PERMIT = ", CI) lBoxCP.DataSource = dssCP.Tables(0) lBoxCP.DisplayMember = "STR_CUTTING_PERMIT"
Does my problem lie with the Where clause??
Thanks in advance, Amber
Hi Amber,
In addition to CJ Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT"
TDT_CUTTING_PERMIT WHERE STR_CUTTING_PERMIT = ", CI)
I did not use the application blocks either,
But this should be connection, command, selectstring, oledbparameter.
You have mixed it a little bit up.
I think the the most simple is (to start) to change the permit in either (if
it is a string or a integer) in
CUTTING_PERMIT = '" & CI & "'") 'string
or
CUTTING_PERMIT = " & CI.tostring ) 'integer
And than place in CI the right value, I think that what now is in it is
absolute wrong.
I hope this helps?
Cor
Cor
I was very unclear on wording my question and problem
What I want to do is base my SQL query on a VB.net text box. so, WHERE STR_CUTTING_PERMIT = txtCPmain.tex
nothing I type seems to work..
In my original example of my code, I made an error, I had made my variable equal to the wrong thing..
I said
Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT
but it would actually be
dim CI as string = txtCPmain.tex
Does this make it a bit clearer
Sorry
Ambe
Amber,
Yes and than try it as I said with at the end
CUTTING_PERMIT = '" & CI & "'")
I hope this works,
Cor
Surely the last line of the SQL statement should be
...STR_SIGN_OFF_COM FROM TDT_CUTTING_PERMIT WHERE STR_CUTTING_PERMIT =
'" & CI & "'")
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
use the command object's parameters.. they make life easier on you
"amber" <an*******@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com... I was very unclear on wording my question and problem.
What I want to do is base my SQL query on a VB.net text box. so, WHERE
STR_CUTTING_PERMIT = txtCPmain.text nothing I type seems to work... In my original example of my code, I made an error, I had made my variable
equal to the wrong thing... I said Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT" but it would actually be dim CI as string = txtCPmain.text
Does this make it a bit clearer?
Sorry. Amber
amber,
Something to consider (from Jeff Levinson book, Building Client/Server
Applications in VB.NET)
Using a TextBox to create a SQL Query is subject to an SQL injection attack.
eg, the following will retrieve all rows from the Books table where the
title matches the text entered by the user
SELECT * FROM dbo.Books WHERE Title = '" & txtTitle.Text & "'
a malicious user could enter the following in the TextBox
' DROP TABLE Books --
The resulting SQL statement would be
SELECT * FROM dbo.Books WHERE Title = '' DROP TABLE Books --
which would result in your table being deleted!
Use stored procedures if possible
Stephen
"amber" <an*******@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com... I was very unclear on wording my question and problem.
What I want to do is base my SQL query on a VB.net text box. so, WHERE
STR_CUTTING_PERMIT = txtCPmain.text nothing I type seems to work... In my original example of my code, I made an error, I had made my variable
equal to the wrong thing... I said Dim CI as string = "TDT_CUTTING_PERMIT.STR_CUTTING_PERMIT" but it would actually be dim CI as string = txtCPmain.text
Does this make it a bit clearer?
Sorry. Amber This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kwan Ting |
last post by:
The_Sage, I see you've gotten yourself a twin asking for program in
comp.lang.c++ .
http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=45cd1b289c71c33c&rnum=1
If you the oh so mighty...
|
by: SkunkDave |
last post by:
Having this description column in a table
"Cookies, peanut butter sandwich, regular"
When using this WHERE clause:
WHERE (((Food_Data.Description) Like "*Butter*" & "*Peanut*"));
I...
|
by: Lauren Quantrell |
last post by:
In VBA, I constructed the following to update all records in
tblmyTable with each records in tblmyTableTEMP having the same
UniqueID:
UPDATE
tblMyTable RIGHT JOIN tblMyTableTEMP ON...
|
by: Martin |
last post by:
Hi
I'm having trouble with the script below that it just won't do a
correct ORDER BY for a date field.
When executing the two SELECT TOP statements on their own the records
are sorted...
|
by: Bryan |
last post by:
I am executing a case statement list below,
USE Northwind
SELECT
MONTH(OrderDate) AS OrderMonth,
SUM(CASE YEAR(OrderDate)
WHEN 1996 THEN 1
ELSE 0
END) AS c1996,
|
by: Mike |
last post by:
Hello,
I have a few rather urgent questions that I hope someone can help with (I
need to figure this out prior to a meeting tomorrow.) First, a bit of
background: The company I work for is...
|
by: egoldthwait |
last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a
Citrix farm. The issue: we have never converted an Access Db to Oracle
but can probably use Oracle's Workbench to assist with...
|
by: AJ |
last post by:
Folllowing on from a previous post, i have created a stored query as follows.
SELECT
c.ID, c.Company_Name, p., 1 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT...
|
by: Jane T |
last post by:
I appreciate how difficult it is to resolve a problem without all the
information but maybe someone has come across a similar problem.
I have an 'extract' table which has 1853 rows when I ask for...
|
by: pbassutti |
last post by:
Hello,
I'm trying to link two tables... one for Employees and the other for
Timecards
I need to get a list of employees that do not have timecards on an
SPECIFIC DATE
I tried the follonwing
|
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...
|
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: 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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |