new to .net and I want to throw it back

  • Thread starter Thread starter Gonzosez
  • Start date Start date
G

Gonzosez

I have the followinf statement
TextBox1.Text = rsVMFG("id")

I get the following message

Unable to cast object of type 'ADODB.InternalField' to type 'System.String'.

Huh????
 
First off, which language are you using?

Second, you can't implicitly convert an object to a string. this is
known as type safety, and is actually a benefit (ever have a bug in the
code b/c you thought you were dealing with an int, but somehow a string
got pushed in there?

At any rate, adding a ToString call:

VB: TextBox1.Text = rsVMFG("id").ToString
C# : TextBox1.Text = rsVMFG["id"].ToString();

HTH
Andy
 
likely :
TextBox1.Text = rsVMFG("id").Value

rsVMFG("id") is a Field object and you try to assing thisto a String...

Patrice
 
Andy said:
First off, which language are you using?

Second, you can't implicitly convert an object to a string. this is
known as type safety, and is actually a benefit (ever have a bug in the
code b/c you thought you were dealing with an int, but somehow a string
got pushed in there?

At any rate, adding a ToString call:

VB: TextBox1.Text = rsVMFG("id").ToString
C# : TextBox1.Text = rsVMFG["id"].ToString();

HTH
Andy
That's just a small part of his problem. He's still using
ADO/Recordsets. Perhaps he should look into ADO.NET first...
 
All good suggestions so far... but many folks out there have to stick with
ADODB (ADO classic) for awhile yet.
Make sure you have "Option Strict = On" and "Option Explicit = On" to make
sure these issues show up in design mode.
Yes, this is an ongoing issue with .NET (object-oriented) development. There
are no "default" properties and the "try-to-guess-what's-needed" code
generator was left out of the .NET Framework... ;)

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________
 
Bill,

Just out of curiosity, why would you be stuck with ADODB if you're
coding in .Net? I've only found myself using it once every in all my
..Net work, and that was because the ODBC .Net provider doesn't allow
for getting a schema.

Andy
 
That's because ADO classic supports a number of features that ADO. NET does
not--and won't for some time. Server-side cursors are one of these
features...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________
 
William said:
That's because ADO classic supports a number of features that ADO.
NET does not--and won't for some time. Server-side cursors are one of
these features...

Though in what context do you really need a server-side cursor other
than a forward-only cursor (which is there in the form of a datareader)
? Isn't it more scalable to pass the resultset to the client, so server
resources can be freed ?

It requires a different way of working with data, fully admitted, but
that doesn't necessary mean a step back, as IMHO it means a step
forward.

FB

--
 
Let's not get into that debate again. There are a number of companies whose
well-designed, perfectly functional applications were designed around the
functionality of a server-side cursor. Yes, they were abused. That does not
mean they should be banned.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
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.
__________________________________
 
William said:
Let's not get into that debate again. There are a number of companies
whose well-designed, perfectly functional applications were designed
around the functionality of a server-side cursor. Yes, they were
abused. That does not mean they should be banned.

It wasn't a start for a debate, I was just curious, as I couldn't
think of a reason to use them myself, so I must overlook something, and
I then want to know what it is that I overlook, that's all. :)

FB

--
 
Back
Top