|
-
May 7th, 2001, 10:58 AM
#1
Ok, SQL gurus
I'm using the data environment designer. I used the SQL builder to generate an SQL that will return a record based on user-selected input (parameter) The SQL should do the following: My program has a global string variable called gloCurrProjNum. Based on which project number selected, the SQL should return the specific record. So far I have used:
SELECT * FROM project WHERE ProjNum = [gloCurrProjNum]
The SQL does not generate any records. What am I doing wrong? Any suggestions would be appreciated. Thanks in advance.
-
May 7th, 2001, 11:01 AM
#2
Re: Ok, SQL gurus
Where (How) does the user input the project number? List box? text box?
-
May 7th, 2001, 11:09 AM
#3
Re: Ok, SQL gurus
This is how the users are selecting the project Num. They are using a datacombo box. The msgbox is just to verify that i'm passing the right parameter (it is).
private Sub DataCombo1_Click(Area as Integer)
If Area = dbcAreaList then
gloCurrProjNum = DataCombo1.Text
MsgBox gloCurrProjNum
End If
End Sub
-
May 7th, 2001, 11:16 AM
#4
Re: Ok, SQL gurus
I use ADO, myself. You could try something similar to the following, assuming you have an active connection already. Does this help, or am I way off base, here?
Private Sub cmdDelete_Click()
gloCurrProjNum = CLng(DataCombo1.Text)
Set objCmd = New ADODB.Command
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = "SELECT * FROM project WHERE ProjNum = " & gloCurrProjNum
objCmd.CommandType = adCmdText
objCmd.Execute
End Sub
-
May 7th, 2001, 11:17 AM
#5
Re: Ok, SQL gurus
try
"SELECT * FROM project WHERE ProjNum = [" & gloCurrProjNum & "]"
Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
May 7th, 2001, 02:59 PM
#6
Re: Ok, SQL gurus
This problem is killing me. If I manually type in a project number in the "value" text box in the parameters tab, The code works fine. The text boxes populate with all the data from the database. If i input [gloCurrProjNum] in the "value" text box in the parameters tab, i got nothing! Any other suggestions?
-
May 7th, 2001, 03:54 PM
#7
Re: Ok, SQL gurus
objCmd.CommandText = "SELECT * FROM project WHERE ProjNum = '" & gloCurrProjNum & "'"
Iouri Boutchkine
[email protected]
-
May 7th, 2001, 03:58 PM
#8
Re: Ok, SQL gurus
You only need the single quotes if gloCurrProjNum is a text string. I converted it to a Long Int first, so you don't need the single quotes.
-
May 8th, 2001, 02:57 AM
#9
Re: Ok, SQL gurus
Hmm, I've noticed that you aren't doing anything with the value of the combo. Where's the code that refreshes the datasource? The datasource won't refresh when the value changes, you will have to do this yourself. For the SQL statement, it look alright, I don't think you must look for the problem there. If the SQL was generated by the dataenvironment, it should work, also when you add a value in the value property of a parameter, it works fine, which makes me even more sure that the problem isn't with the SQL
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
May 8th, 2001, 08:31 AM
#10
Re: Ok, SQL gurus
if the project number is a number then
"SELECT * FROM project WHERE ProjNum = " & val(gloCurrProjNum)
if the project number is a string then
"SELECT * FROM project WHERE ProjNum = '" & gloCurrProjNum & "'"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|