Column names with spaces

  • Thread starter Thread starter steven_licciardinnoossppaamm
  • Start date Start date
S

steven_licciardinnoossppaamm

Does anyone have an example of constructing command
strings using column names with spaces? For example I
have :

Dim strCommUpd As String = "UPDATE DTable SET [AESLRef]=@
[AESLRef], [Test Column]=@[Test Column] WHERE ID=@ID"

My parameters would then take the form:

commUpd.Parameters.Add("@[AESLRef]", sqlDBType.VarChar,
50, "[AESLRef]")

commUpd.Parameters.Add("@[Test Column]",
sqlDBType.DateTime, 8, "[Test Column]")

When I try and do an update to save changes in the data I
get an error of the form : Incorrect syntax near 'varchar'

If I get rid of the varchar column then the error
specifies the next type (i.e. Incorrect syntax
near 'datetime')

This is the same code that works for the column names
without spaces so I can only assume I have an error
somewhere else.

Thanks,

Steven
 
Stop. Do yourself a BIG favor and take out the spaces in object names. Yes,
there are ways to get this to work, but as soon as you get part of your app
working, another part will choke.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"(e-mail address removed)"
 
Back
Top