General discussion

Locked

Passing VB6.0 Text into Sql 7 Query

By FullOfHope ·
I am trying to query a sql database in wich the user enters a date range in a text box and the the query uses this info to parse out
the information using that date range...

Im not having much luck...
would aprecciate any help

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Passing VB6.0 Text into Sql 7 Query

by Sheryl V In reply to Passing VB6.0 Text into S ...

Are you using 2 text boxes(e.g., txtStart & txtEnd)?
If so are you forcing "#" at the beginning and end of each date?

Where myDate >= "#" & txtStart & "#" and myDate <= "#" & txtEnd & "#"
Hope this helps.

Collapse -

Passing VB6.0 Text into Sql 7 Query

by FullOfHope In reply to Passing VB6.0 Text into S ...

I needed to be more Specific in my question I can't seem to pass any Parameter into the sql statement. I keep getting invalid field.
so I need the proper syntax ...
IE...
SELECT * FROM datatable
WHERE blank = textbox

Collapse -

Passing VB6.0 Text into Sql 7 Query

by FullOfHope In reply to Passing VB6.0 Text into S ...

I should have phrased the question better I need to know the proper syntax for passing parameters into the sql statement I keep getting invalid colum or field name when I try..

select * from datasource where
tr_date > sdate

sdate being a txtbox.

Collapse -

Passing VB6.0 Text into Sql 7 Query

by Sheryl V In reply to Passing VB6.0 Text into S ...

I think that SQL can not tell that sdate is a date field so instead of:

select * from datasource where
tr_date > sdate

You may need to qualify it:

select * from datasource where
tr_date > "#" & sdate & "#"

Let me know if it works out.

Collapse -

Passing VB6.0 Text into Sql 7 Query

by FullOfHope In reply to Passing VB6.0 Text into S ...

Poster rated this answer

Collapse -

Passing VB6.0 Text into Sql 7 Query

by roc180 In reply to Passing VB6.0 Text into S ...

Use the following syntax:

strSQL="SELECT * FROM datasource
WHERE tr_date = '"& sdate &"' ;"

strSQL is a string variable that contains your query. Other things to make sure you are doing correctly:
1.Make sure tr_date is the actual nameof your field in the SQL Server table datasource.
2. When using dates in SQL Server enclose the dates with (' ').
3. Whatever your using to execute the query (Recordset,Command Object, etc..) make sure it can see the SQL Server table.

If you are still getting an error send me your blurb of code and I can take a look at it.

Good Luck

Neal Martinelli

Collapse -

Passing VB6.0 Text into Sql 7 Query

by FullOfHope In reply to Passing VB6.0 Text into S ...

Poster rated this answer

Collapse -

Passing VB6.0 Text into Sql 7 Query

by FullOfHope In reply to Passing VB6.0 Text into S ...

This question was closed by the author

Back to Web Development Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums