Jump to content

DB Field names


Recommended Posts

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?

Link to comment
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]

Link to comment
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?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...