Ask a Question related to ASP.NET General, Design and Development.
-
Ravikanth[MVP] #1
Question: Best way to handle DBNULL in datareaders
Hi
Alternative is check before assigning as TextBox value.
TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
(string)myRow["ColumnName"]
HTH
Ravikanth
datareaders.>-----Original Message-----
>Im looking for the best way to handle DBNULL's inoptional data with>
>In a project im currently working on im using a lot offield contains a>datareaders.
>
>Using the following syntax im getting errors when thefunction of MSSQL and>DBNULL value
>Textbox1.text = myreader(1)
>
>My current solution for this is using the isnulltyping for me, which>substituting null's with "" there. This means a lot of>is never a good thing.
>
>Does anyone have a better solution to my problem?
>
>
>.
>Ravikanth[MVP] Guest
-
DBNull problems - typed datasets - webservices
I'm using a typed dataset to get rows from a database, but getting an invalid cast exception when trying to examine columns in that row which are... -
paging with datareaders
Hey people, When a datareader is used for paging with a datagrid in asp.net, we have to use the custom paging method ? How do we find out the... -
How to check if CType(e.Item.DataItem, DataRowView) is DBNULL
How do you check if CType(e.Item.DataItem, DataRowView) is DBNULL? I have a Datagrid with Edit,Update, and Insert buttons to a SQL data table. ... -
Cast from type 'DBNull' to type 'String' is not valid error
Trying to add an insert button Sub btnAddRow_Click event for adding a row to the datagrid and dataset back to SQL. Had it working per the... -
Question: Handle Events From Web User Controls
I was reading an article that talked about using the OnBubbleEvent overrides function to handle events from a web user control... -
Aemca #2
Re: Question: Best way to handle DBNULL in datareaders
That was my first solution but thats way 2 much work to type that for each
value i want to use.
So this is not really a better solution for me.
> Hi
>
> Alternative is check before assigning as TextBox value.
>
> TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> (string)myRow["ColumnName"]
>
> HTH
> Ravikanth
>
>> datareaders.> >-----Original Message-----
> >Im looking for the best way to handle DBNULL's in> optional data with> >
> >In a project im currently working on im using a lot of> field contains a> >datareaders.
> >
> >Using the following syntax im getting errors when the> function of MSSQL and> >DBNULL value
> >Textbox1.text = myreader(1)
> >
> >My current solution for this is using the isnull> typing for me, which> >substituting null's with "" there. This means a lot of> >is never a good thing.
> >
> >Does anyone have a better solution to my problem?
> >
> >
> >.
> >
Aemca Guest
-
Re: Question: Best way to handle DBNULL in datareaders
You could make a function which wraps the null and put that in...
Textbox1.text = CleanThis(myreader(1))
Have you tried adding the null to an empty string?
Textbox1.text = "" & myreader(1)
or something like that
It's not clear if you are using getstring or getvalue or what
....?
"Aemca" <none@none.com> wrote in message
news:eCQJpFGTDHA.2852@tk2msftngp13.phx.gbl...> That was my first solution but thats way 2 much work to type that for each
> value i want to use.
>
> So this is not really a better solution for me.
>
>>> > Hi
> >
> > Alternative is check before assigning as TextBox value.
> >
> > TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> > (string)myRow["ColumnName"]
> >
> > HTH
> > Ravikanth
> >
> >> > datareaders.> > >-----Original Message-----
> > >Im looking for the best way to handle DBNULL's in> > optional data with> > >
> > >In a project im currently working on im using a lot of> > field contains a> > >datareaders.
> > >
> > >Using the following syntax im getting errors when the> > function of MSSQL and> > >DBNULL value
> > >Textbox1.text = myreader(1)
> > >
> > >My current solution for this is using the isnull> > typing for me, which> > >substituting null's with "" there. This means a lot of> > >is never a good thing.
> > >
> > >Does anyone have a better solution to my problem?
> > >
> > >
> > >.
> > >
>
Guest
-
Aemca #4
Re: Question: Best way to handle DBNULL in datareaders
any suggestions on how to implement this ?
aka what should be in there
and this is the way that it is implemented, the .getvalue / getstring are
omitted.
<DanR@REMOVETHISTOGETTOME-warshawgroup.com> wrote in message
news:#pz2GmGTDHA.2148@TK2MSFTNGP10.phx.gbl...each> You could make a function which wraps the null and put that in...
>
> Textbox1.text = CleanThis(myreader(1))
>
> Have you tried adding the null to an empty string?
>
> Textbox1.text = "" & myreader(1)
>
> or something like that
>
> It's not clear if you are using getstring or getvalue or what
>
> ...?
>
> "Aemca" <none@none.com> wrote in message
> news:eCQJpFGTDHA.2852@tk2msftngp13.phx.gbl...> > That was my first solution but thats way 2 much work to type that for>> > value i want to use.
> >
> > So this is not really a better solution for me.
> >
> >> >> > > Hi
> > >
> > > Alternative is check before assigning as TextBox value.
> > >
> > > TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> > > (string)myRow["ColumnName"]
> > >
> > > HTH
> > > Ravikanth
> > >
> > >
> > > >-----Original Message-----
> > > >Im looking for the best way to handle DBNULL's in
> > > datareaders.
> > > >
> > > >In a project im currently working on im using a lot of
> > > optional data with
> > > >datareaders.
> > > >
> > > >Using the following syntax im getting errors when the
> > > field contains a
> > > >DBNULL value
> > > >Textbox1.text = myreader(1)
> > > >
> > > >My current solution for this is using the isnull
> > > function of MSSQL and
> > > >substituting null's with "" there. This means a lot of
> > > typing for me, which
> > > >is never a good thing.
> > > >
> > > >Does anyone have a better solution to my problem?
> > > >
> > > >
> > > >.
> > > >
> >
>
Aemca Guest
-
PJ #5
Re: Question: Best way to handle DBNULL in datareaders
You can simply use .ToString() on varchar fields.
dr(0).ToString()
That will return an empty string if it's a null varchar field.
"Aemca" <none@none.com> wrote in message
news:urhX2zGTDHA.2084@TK2MSFTNGP11.phx.gbl...> any suggestions on how to implement this ?
> aka what should be in there
>
> and this is the way that it is implemented, the .getvalue / getstring are
> omitted.
>
>
> <DanR@REMOVETHISTOGETTOME-warshawgroup.com> wrote in message
> news:#pz2GmGTDHA.2148@TK2MSFTNGP10.phx.gbl...> each> > You could make a function which wraps the null and put that in...
> >
> > Textbox1.text = CleanThis(myreader(1))
> >
> > Have you tried adding the null to an empty string?
> >
> > Textbox1.text = "" & myreader(1)
> >
> > or something like that
> >
> > It's not clear if you are using getstring or getvalue or what
> >
> > ...?
> >
> > "Aemca" <none@none.com> wrote in message
> > news:eCQJpFGTDHA.2852@tk2msftngp13.phx.gbl...> > > That was my first solution but thats way 2 much work to type that for>> >> > > value i want to use.
> > >
> > > So this is not really a better solution for me.
> > >
> > >
> > > > Hi
> > > >
> > > > Alternative is check before assigning as TextBox value.
> > > >
> > > > TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> > > > (string)myRow["ColumnName"]
> > > >
> > > > HTH
> > > > Ravikanth
> > > >
> > > >
> > > > >-----Original Message-----
> > > > >Im looking for the best way to handle DBNULL's in
> > > > datareaders.
> > > > >
> > > > >In a project im currently working on im using a lot of
> > > > optional data with
> > > > >datareaders.
> > > > >
> > > > >Using the following syntax im getting errors when the
> > > > field contains a
> > > > >DBNULL value
> > > > >Textbox1.text = myreader(1)
> > > > >
> > > > >My current solution for this is using the isnull
> > > > function of MSSQL and
> > > > >substituting null's with "" there. This means a lot of
> > > > typing for me, which
> > > > >is never a good thing.
> > > > >
> > > > >Does anyone have a better solution to my problem?
> > > > >
> > > > >
> > > > >.
> > > > >
> > >
> > >
> >
>
PJ Guest
-
Aemca #6
Re: Question: Best way to handle DBNULL in datareaders
"PJ" <pjwal@hotmail.com> wrote in message
news:ODfDfQITDHA.2180@TK2MSFTNGP10.phx.gbl...are> You can simply use .ToString() on varchar fields.
>
> dr(0).ToString()
>
> That will return an empty string if it's a null varchar field.
>
> "Aemca" <none@none.com> wrote in message
> news:urhX2zGTDHA.2084@TK2MSFTNGP11.phx.gbl...> > any suggestions on how to implement this ?
> > aka what should be in there
> >
> > and this is the way that it is implemented, the .getvalue / getstringfor> > omitted.
> >
> >
> > <DanR@REMOVETHISTOGETTOME-warshawgroup.com> wrote in message
> > news:#pz2GmGTDHA.2148@TK2MSFTNGP10.phx.gbl...> > > You could make a function which wraps the null and put that in...
> > >
> > > Textbox1.text = CleanThis(myreader(1))
> > >
> > > Have you tried adding the null to an empty string?
> > >
> > > Textbox1.text = "" & myreader(1)
> > >
> > > or something like that
> > >
> > > It's not clear if you are using getstring or getvalue or what
> > >
> > > ...?
> > >
> > > "Aemca" <none@none.com> wrote in message
> > > news:eCQJpFGTDHA.2852@tk2msftngp13.phx.gbl...
> > > > That was my first solution but thats way 2 much work to type that>> > each> >> > > > value i want to use.
> > > >
> > > > So this is not really a better solution for me.
> > > >
> > > >
> > > > > Hi
> > > > >
> > > > > Alternative is check before assigning as TextBox value.
> > > > >
> > > > > TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> > > > > (string)myRow["ColumnName"]
> > > > >
> > > > > HTH
> > > > > Ravikanth
> > > > >
> > > > >
> > > > > >-----Original Message-----
> > > > > >Im looking for the best way to handle DBNULL's in
> > > > > datareaders.
> > > > > >
> > > > > >In a project im currently working on im using a lot of
> > > > > optional data with
> > > > > >datareaders.
> > > > > >
> > > > > >Using the following syntax im getting errors when the
> > > > > field contains a
> > > > > >DBNULL value
> > > > > >Textbox1.text = myreader(1)
> > > > > >
> > > > > >My current solution for this is using the isnull
> > > > > function of MSSQL and
> > > > > >substituting null's with "" there. This means a lot of
> > > > > typing for me, which
> > > > > >is never a good thing.
> > > > > >
> > > > > >Does anyone have a better solution to my problem?
> > > > > >
> > > > > >
> > > > > >.
> > > > > >
> > > >
> > > >
> > >
> > >
> >
>
Aemca Guest
-
Aemca #7
Re: Question: Best way to handle DBNULL in datareaders
thx :)
"PJ" <pjwal@hotmail.com> wrote in message
news:ODfDfQITDHA.2180@TK2MSFTNGP10.phx.gbl...are> You can simply use .ToString() on varchar fields.
>
> dr(0).ToString()
>
> That will return an empty string if it's a null varchar field.
>
> "Aemca" <none@none.com> wrote in message
> news:urhX2zGTDHA.2084@TK2MSFTNGP11.phx.gbl...> > any suggestions on how to implement this ?
> > aka what should be in there
> >
> > and this is the way that it is implemented, the .getvalue / getstringfor> > omitted.
> >
> >
> > <DanR@REMOVETHISTOGETTOME-warshawgroup.com> wrote in message
> > news:#pz2GmGTDHA.2148@TK2MSFTNGP10.phx.gbl...> > > You could make a function which wraps the null and put that in...
> > >
> > > Textbox1.text = CleanThis(myreader(1))
> > >
> > > Have you tried adding the null to an empty string?
> > >
> > > Textbox1.text = "" & myreader(1)
> > >
> > > or something like that
> > >
> > > It's not clear if you are using getstring or getvalue or what
> > >
> > > ...?
> > >
> > > "Aemca" <none@none.com> wrote in message
> > > news:eCQJpFGTDHA.2852@tk2msftngp13.phx.gbl...
> > > > That was my first solution but thats way 2 much work to type that>> > each> >> > > > value i want to use.
> > > >
> > > > So this is not really a better solution for me.
> > > >
> > > >
> > > > > Hi
> > > > >
> > > > > Alternative is check before assigning as TextBox value.
> > > > >
> > > > > TextBox1.Text =myRow["ColumnName"]==DBNull.Value)?"":
> > > > > (string)myRow["ColumnName"]
> > > > >
> > > > > HTH
> > > > > Ravikanth
> > > > >
> > > > >
> > > > > >-----Original Message-----
> > > > > >Im looking for the best way to handle DBNULL's in
> > > > > datareaders.
> > > > > >
> > > > > >In a project im currently working on im using a lot of
> > > > > optional data with
> > > > > >datareaders.
> > > > > >
> > > > > >Using the following syntax im getting errors when the
> > > > > field contains a
> > > > > >DBNULL value
> > > > > >Textbox1.text = myreader(1)
> > > > > >
> > > > > >My current solution for this is using the isnull
> > > > > function of MSSQL and
> > > > > >substituting null's with "" there. This means a lot of
> > > > > typing for me, which
> > > > > >is never a good thing.
> > > > > >
> > > > > >Does anyone have a better solution to my problem?
> > > > > >
> > > > > >
> > > > > >.
> > > > > >
> > > >
> > > >
> > >
> > >
> >
>
Aemca Guest



Reply With Quote

