|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
new to .net and I want to throw it backI 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 Andy wrote:
Show quote > First off, which language are you using? That's just a small part of his problem. He's still 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 > ADO/Recordsets. Perhaps he should look into ADO.NET first... likely :
TextBox1.Text = rsVMFG("id").Value rsVMFG("id") is a Field object and you try to assing thisto a String... Patrice -- Show quote"Gonzosez" <nospam@home.com> a écrit dans le message de news:eqrONGEIGHA.2460@TK2MSFTNGP10.phx.gbl... > 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???? > > 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 -- Show quote____________________________________ 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. __________________________________ "Gonzosez" <nospam@home.com> wrote in message news:eqrONGEIGHA.2460@TK2MSFTNGP10.phx.gbl... >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???? > > 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... -- Show quote____________________________________ 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. __________________________________ "Andy" <ajohnst***@capcitypress.com> wrote in message news:1138113828.746400.293030@g47g2000cwa.googlegroups.com... > 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 > William (Bill) Vaughn wrote:
> That's because ADO classic supports a number of features that ADO. Though in what context do you really need a server-side cursor other> NET does not--and won't for some time. Server-side cursors are one of > these features... 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 -- ------------------------------------------------------------------------ Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma Microsoft MVP (C#) ------------------------------------------------------------------------ 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. -- Show quote____________________________________ 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. __________________________________ "Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xs4all.nl> wrote in message news:xn0ehnex45asv1001@news.microsoft.com... > William (Bill) Vaughn wrote: > >> 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 > > -- > ------------------------------------------------------------------------ > Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com > My .NET blog: http://weblogs.asp.net/fbouma > Microsoft MVP (C#) > ------------------------------------------------------------------------ William (Bill) Vaughn wrote:
> Let's not get into that debate again. There are a number of companies It wasn't a start for a debate, I was just curious, as I couldn't> 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. 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 -- ------------------------------------------------------------------------ Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma Microsoft MVP (C#) ------------------------------------------------------------------------ |
|||||||||||||||||||||||