.NETGURU
spaces and special characters in field names, brackets don't work
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Yall (VIP)
When I had non standard field names I used to be able to do this in VB6 and
Access97. Now using Access2002 and VB.net. I inherited this data base and
have to use the field names with special characters and spaces.

Now in VB.net it gives me and error.

If I don't use the fields that have brackets, things work OK, if I use *
instead of naming fields it fails in the same way because of the space and
the # in the name of the two fields.

The brackets [ ] used to work for a field that had a space or special
character in it. Do you know how to do this in VB.net and Access2002?

strSQL = "SELECT StreamID, SolidWasteCode, Approved, "
strSQL = strSQL & "Description, SolidWasteDescription, Category,
"
strSQL = strSQL & "[STPStream#], [EPA Code] "
strSQL = strSQL & "FROM WasteStream;"

Dim da1 As New OleDbDataAdapter
Dim ds1 As New DataSet

da1.SelectCommand = New OleDbCommand(strSQL, OleDbConnection1)

Dim NewWasteStream As OleDbCommandBuilder = New
OleDbCommandBuilder(da1)
da1.Fill(ds1)

Dim dr1 As DataRow = ds1.Tables(0).NewRow

If Not ds1 Is Nothing Then

dr1("StreamID") = Me.txtStreamID.Text & ""
dr1("STPStream#") = Me.txtSTPStream.Text & ""
dr1("EPA Code") = Me.txtEPA_Code.Text & ""
ds1.Tables(0).Rows.Add(dr1)

da1.Update(ds1)

End If

Reply to this message...
 
    
Marina
They still work. The issue is, that the column names in the dataset, get
the brackets stripped off.

Set QuotePrefix and QuoteSuffix on the command builder to [ and ].

"Yall" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> When I had non standard field names I used to be able to do this in VB6
and
[Original message clipped]

Reply to this message...
 
    
Yall (VIP)
How do I "Set QuotePrefix and QuoteSuffix on the command builder to [ and ]."?

"Marina" wrote:

[Original message clipped]

Reply to this message...
 
    
Marina
Have you ever set properties on an object before? You must have, otherwise
you wouldn't have been able to write this code... so I'm very confused about
your question.

"Yall" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> How do I "Set QuotePrefix and QuoteSuffix on the command builder to [
and ]."?
[Original message clipped]

Reply to this message...
 
    
Yall (VIP)
I am at a remote site and not near my project's computer right now, sorry. I
have really been struggling with this and am tired too LOL

I guess it would be something like this?

NewWasteStream.QuotePrefix = "["

After I built the

Dim NewWasteStream As OleDbCommandBuilder = New OleDbCommandBuilder(da1)

in the below code

"Marina" wrote:

[Original message clipped]

Reply to this message...
 
    
Marina
Yes, that would be it.

"Yall" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> I am at a remote site and not near my project's computer right now, sorry.
I
[Original message clipped]

Reply to this message...
 
    
Yall (VIP)
Thanks you so much Marina, I really struggled for two weeks with this. I
really appreciate your prompt and helpful response.

It worked like a champ!

::HUGZ::

"Marina" wrote:

[Original message clipped]

Reply to this message...
 
    
William \(Bill\) Vaughn
Do yourself (and those that have to inherit this code) a favor. Get rid of
the imbedded spaces in your object names. You might have fixed this problem,
but you'll constantly be having problems like this crop up forever you
don't.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________

"Yall" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Data.DataRow
System.Data.DataSet
System.Data.OleDb.OleDbCommand
System.Data.OleDb.OleDbCommandBuilder
System.Data.OleDb.OleDbDataAdapter




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification