Space in table name problem
-
Hi, when I try to read in data to a dataset and the table name has a space in it, I get an exception that the table doesn't exist. For some reason, only the part of the table name up to the space is recognised. Do I need to escape the space in a special way or try some other method? Thanks. ...code.... String sTable = "Table space". dataAdapter.File(dataSet,sTable); //exception here...., tries to load "Table" "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
-
Hi, when I try to read in data to a dataset and the table name has a space in it, I get an exception that the table doesn't exist. For some reason, only the part of the table name up to the space is recognised. Do I need to escape the space in a special way or try some other method? Thanks. ...code.... String sTable = "Table space". dataAdapter.File(dataSet,sTable); //exception here...., tries to load "Table" "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
Spaces in database object names are a terrible idea, use _ in future. For now, I believe that wrapping the name in square brackets will fix the problem. I know that works for reserved names. If I am wrong, try single quotes, but that seems a lot less likely to me. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Spaces in database object names are a terrible idea, use _ in future. For now, I believe that wrapping the name in square brackets will fix the problem. I know that works for reserved names. If I am wrong, try single quotes, but that seems a lot less likely to me. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
Hi, thanks, it's not my data file, so I can't control the use of spaces. I've tried wrapping it in square brackets, but it still throws an exception and seems to ignore the part of the name after the space, also does this if I replace the space with an underscore, quite weird. "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
-
Hi, thanks, it's not my data file, so I can't control the use of spaces. I've tried wrapping it in square brackets, but it still throws an exception and seems to ignore the part of the name after the space, also does this if I replace the space with an underscore, quite weird. "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
Hi, that suggestion of yours worked great, I'd just put it in after the necessary place in the code. Thanks heaps. "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
-
Hi, that suggestion of yours worked great, I'd just put it in after the necessary place in the code. Thanks heaps. "Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
No worries. The _ will only work if the table is named that way to start with, you can't use one for the other :-) The [] is generally a good way to show SQL what you mean when it's not clear, for example if you name a table Index, it won't work without the [] to show that the reserved word is meant as a name. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder