Conversion from type 'DBNull' to type 'String' is not valid

Hello Friends

           How are you?? Friends i am getting problem in SQL Server 2005. I am deployng web application on production server as well as Databse also. In production server i inserted new field in all tables which is rowguid and its type is uniqueidentifier. The default binding for this field is newsequentialid(). In some pages it works ok but in some places it generates error like 'Conversion from type 'DBNull' to type 'String' is not valid'. Can anybody help me to solve this problem. Its urgent so plz reply me as soon as possible. I'll be very thankfull to you. Thanks in Advance.

 Regards,


Zeeshan
0
zeeshanfawad
3/7/2008 7:17:48 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
893 Views

Similar Articles

[PageSpeed] 20

string submissionBatchID = Convert.string (cmd.ExecuteScalar().GetType() == typeof(DBNull) ? "0" : cmd.ExecuteScalar());

 

see i am first checking the oudput of filed if the file is null then returing 0 else returning value then converting to string

or in acse just check before converting to string


Thanks and Regards
Somnath
Please click “Mark as Answer” on the post if it helps you,
0
Som
3/7/2008 10:20:09 AM
Reply:

Similar Artilces:

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

Conversion from type 'DBNull' to type 'String' is not valid.
On line 65 of Events_Calendar.aspx- <div style="padding: 3px;"> <asp:HyperLink ID="HyperLink1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%# "Events_view.aspx?Eventid=" &CStr( Eval("ID"))%>' ToolTip='<%# truncate(CStr(Eval("description"))) %>' /></div> The debugger tells me "InvalidCastException unhandled by user code" I found out that the data entry form for events allows the user to leave the description field empty.  So this translates to NULL in the SQL Server 2005 database.  the NULL value in the description field...

Conversion from type 'DBNull' to type 'String' is not valid...
Thanks for your time.  Getting following error when grid source populates a rows Date field with Null:     - Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.It works works when I filter the nulls out, but I need to show all rows in the grid. Boils down to:  a) How could I maintain a blank value in the grid and cast this properly to include all rows?    < or >  b) Is there a way to default a value that isnt a date (to avoid the null & keep the IsDate logic as is)  c) ...

Conversion from type 'DBNull' to type 'String' is not valid.
 Hello Experts,I am reading data into a datagrid and am checking for nullsHere is the code in the datagrid which checks a function in the code-behind:<ItemTemplate>    <asp:Label id="Label2" runat="server" text='<%# GetPickUpDate(container.dataitem("ActualPickUpDate"))%>'></asp:Label></ItemTemplate> Here is the funtion:Function GetPickUpDate(ByVal DateVal As Date) As String            If Not IsDBNull(DateVal) Then     &nb...

Conversion from type 'DBNull' to type 'String' is not valid.
Hi,it's me again...I'm having error withDim Accesstring As String = ("SELECT     FirstName, LastName, Email, StreetAddress, City, Country, State, Zip, Worknum, googlecheckout, paypal, csftcc, confirmationcode FROM dbo.reservation WHERE (confirmationcode = @concode)")            Dim cmd3 As New SqlCommand(Accesstring, icnnn)            cmd3.Parameters.Add("@concode", SqlDbType.NChar).Value = onlineconfirmationcode.Text   &...

I get Conversion from type 'DBNull' to type 'String' is not valid.
I get the following errors when I try and access certain pages.  It is caused by not populating all the text boxes with data and subsequent viewing causes these conversion errors.  Does any one else experience this?  How have you guys worked around this problem? Conversion from type 'DBNull' to type 'String' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Conversion f...

Conversion from type 'DBNull' to type 'String' is not valid #2
I'm getting a error message saying: Server Error in '/' Application. Conversion from type 'DBNull' to type 'String' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.Source Error: Line 113: </h3> Line 114: ...

Conversion from type 'DBNull' to type 'String' is not valid #2
i have with my DB fetch content is Ogject class so i am not use any dataset or datatable but i have problem when field in DB is empty i can insert DBNull in string like this curr.visible = r("visible") curr.title = r("title")curr.description = r("description") curr.price = r("price")   how can i  solve this problem without put if with every insert code fedailr:curr.visible = r("visible") curr.title = r("title")curr.description = r("description") curr.price = r("price") So I assume r ...

Bound TextBox error: Conversion from type 'DBNull' to type 'String' is not valid
 Hi,I use DataSet designer to generate my strongly typed datasets and to bind my FormView to a Business Layer (BLL). The BLL uses the generated Dataset classes. I have a column  in the DB of type string. The column is bound to a textbox like this:Text='<%# Bind("Local") %>'  If the column has a value, thingts work well, but  When the column has a null value, I get the error: Conversion from type 'DBNull' to type 'String' is not validWhat can I do Please? Thanks a lot, I appreciate your taking the time to help me. ...

Conversion from type 'DBNull' to type 'Boolean' is not valid.
Hi all I'm creating a multiple view form using FormViews within a Wizard control. I've been working my way through various problems and I'm getting close but get the following error when I try to Update. System.InvalidCastException was unhandled by user code  Message="Conversion from type 'DBNull' to type 'Boolean' is not valid."  Source="Microsoft.VisualBasic"  StackTrace:       at Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(Object Value)        at ASP.Referral_aspx.__DataBinding__control287(Obj...

Web resources about - Conversion from type 'DBNull' to type 'String' is not valid - asp.net.sql-datasource

Resources last updated: 12/3/2015 12:41:20 AM