Sign in to follow this  
Followers 0
Silver21uk

DB Field names

4 posts in this topic

OK sorry if this is a lil school boy error.

Im accessing data from a database, unfortunatly there are spaces in the feild names, this i cannot change as it is used by another program. When there are no spaces i can run queries fine. however with spaces the query fails.

fails when like this

$oRS.Open("SELECT * FROM Students WHERE Student Ref No = 'ADA05027867'", $oConn, 1, 3)

Works like this

$oRS.Open("SELECT * FROM Students WHERE StudentRefNo = 'ADA05027867'", $oConn, 1, 3)

I need the spaces as stated above. Ive tried

$oRS.Open("SELECT * FROM Students WHERE 'Student Ref No' = 'ADA05027867'", $oConn, 1, 3)

but the query does not report the correct information

any ideas?

Share this post


Link to post
Share on other sites



Welcome to the forums.

I'm sorry that I do not have an answer for you - but I'll give this post a free bump to the top of the forum list. Maybe someone who has worked with this type of script will be able to help you out.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Silver21uk

If you are using MS-SQL, try use square brackets around the field names.

$oRS.Open("SELECT * FROM Students WHERE [Student Ref No] = 'ADA05027867'", $oConn, 1, 3)

Dougie

OK sorry if this is a lil school boy error.

Im accessing data from a database, unfortunatly there are spaces in the feild names, this i cannot change as it is used by another program. When there are no spaces i can run queries fine. however with spaces the query fails.

fails when like this

$oRS.Open("SELECT * FROM Students WHERE Student Ref No = 'ADA05027867'", $oConn, 1, 3)

Works like this

$oRS.Open("SELECT * FROM Students WHERE StudentRefNo = 'ADA05027867'", $oConn, 1, 3)

I need the spaces as stated above. Ive tried

$oRS.Open("SELECT * FROM Students WHERE 'Student Ref No' = 'ADA05027867'", $oConn, 1, 3)

but the query does not report the correct information

any ideas?

Share this post


Link to post
Share on other sites

Hey there cheers boss, exactly what i like to see when i come into work, answers not more questions, head scratching, wall butting.

cheers boss works now.

new it would be something cheecky

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0