Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent!!!!

Status
Not open for further replies.

walkerdigest

Programmer
Feb 10, 2009
35
TR
sql="select * from tblHastabilgikisisel where id=39193"
set rs=conn.execute(sql)


sql sentence works without where clause(so 2nd sentence works). such an id exists.
if I copy select statement to mssql it runs and finds specific person. but sql statement doesn't work in ASP code
what coulde be the problem.
 
What's the error msg you get?

Is the ID in the db a text or numeric field?



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
^ futher to this - a title of "URGENT" means nothing - everyone's requests are URGENT and they would like them resolved as soon as possible -please try and be more descriptive with your titles.

I.E. SQL statement working in DB but not in ASP Code



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Hi,
Is the ID a numeric or character field in the database?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
id is numeric. but also tried with ' . there is no error message . it doesn't give any result and I can not pull any data from database. Please help ....
 
Can we assume you have properly connected to your database and made command and recordet objects?

Are you able to get nothing to work?
 
Maybe provide some more code that is around the select statement(say 10 lines before and after) - be sure to "xxxx" out any usernames and passwords :)

walkerdigest said:
id is numeric. but also tried with ' . there is no error message . it doesn't give any result and I can not pull any data from database. Please help ....

Try a "view source" on the page and see if there is an error message at the very bottom - sometimes error messages don't get sent to the browser due to the spot they are located within the code.

BigRed1212 said:
Can we assume you have properly connected to your database and made command and recordet objects?

Are you able to get nothing to work?

He mentioned that it works within the ASP page without the where clause, so I guess it's all connected properly.

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Hi,
Since it works without the where clause, try writing out the SQL statement ( or make it a label text ) after you set it to be sure it is being sent correctly in the rs=conn.execute(sql) step ( maybe the = operator needs a space before and after)



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
<%

sqlservername ="**.**.***.***"
sqlusername ="****"
sqlpassword ="*****"
sqldatabase ="*********"

set conn = server.createobject("ADODB.Connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=" & sqlservername & ";UID=" & sqlusername & ";PWD=" & sqlpassword & ";DATABASE=" & sqldatabase
%>

above is my connection file

whenever my sql sentence(ASP) without where statement it runs. with where statements doesn't work.

with where statement in SQL Server statement works.That is such a record exists.
How can solve this problem?
 
If Turkbear's and vicvirk's suggestions don't solve things, you should post your code that is accessing the resocrdset, to see if there is a problem there.

In fact, try running the below code and post back the results:

Code:
On Error Resume Next
sql="select * from tblHastabilgikisisel where id=39193"
set rs=conn.execute(sql)
if err.number <> 0 then response.write "Got err#" & err.number & ": " & err.description
on error goto 0
if rs.EOF and rs.BOF then response.write "Recordset is empty"
response.write "sql used: " & sql
response.end
 
I have copied down above code to after my rs statement.
But it didn't give any result....
 
Did you do a view source of the page to see if you received an error message at the bottom of the source code?

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Vicvirk,
how can I do view source of the page?

I am writing the code and copying the file to server and test it.
 
by the way, I am using ASP not ASP.NET. Editing my code with dreamweaver.
 
> how can I do view source of the page
In IE/Firefox: View --> Source

>I have copied down above code to after my rs statement. But it didn't give any result....
Well... the code I gave you should at LEAST be showing you the sql statement (response.write "sql used: " & sql)... so that tells me that you are not executing the code you think you are, or an error is being suppressed as vicvirk is suggesting.
 
The code given worked.

I found out the problem. Problem was that:

ID is my primary key. in sql sentence I've written down id instead of ID(in SQL table originally written as ID)
but in another sql sentence I could write ad instead of Ad(in SQL table) and it worked.....

 
Now in another select sql statement I got following error:

err# 2147217908 command text was not set for the command object . I've given my connection file above.

What could be the problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top