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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO SQL Server Problem

Status
Not open for further replies.

Deleco

Programmer
Feb 25, 2002
109
0
0
GB
I am migrating an access database to SQL Server. I have a front end appliction which uses ADO to access the access database. I use to add a new record to a table as shown.

rs.addnew
rs.fields("Field 1").value = "Field 1"
rs.fields("Field 2").value = "Field 2"
rs.fields("Field 3").value = "Field 3"
rs.update

This was fine when using access, now i have migrated to SQL Server when i try and add a record as above i get an error 'Line1: Incorrect syntax near 1'. I have discovered that this is because of the spaces in the field names, once the spaces are removed it works fine. I was just wondering if anyone new how i could get around this problem without removing the spaces from the fields in the database, as it means a lot more work.

Any help would be gratefully appreciated
Deleco :)
Deleco
 
I think you have to take field name in square parenthesis:

rs.Fields("[Field 1]").value

or use field number:

rs.Fields(0) = ""
rs.Fields(1) = ""
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top