Allow Null Values, And Return A String To The User If No Date If Specified?
Mar 9, 2010I want to create a custom date type. I want to allow null values, and return a string to the user if no date if specified.
View 13 RepliesI want to create a custom date type. I want to allow null values, and return a string to the user if no date if specified.
View 13 RepliesHow can i return null values in if statement above. This statement is not working if condtion is false its retruning me 0 value even if condition is false
dim d as nullable(0f Decimal)
d=(if(_dr("value") isnot dbnull.value,Convert.toDecimal((_dr("value")),Nothing)
I have a FormView where I pull data from one table (MS Access), and then insert it (plus more data) into another table. I'm having issues with the dates.The first table has two date fields: date_submitted and date_updated. In some records, date_updated is blank. This causes me to get a data mismatch error when attempting to insert into the second table.It might be because I'm databinding the date_updated field from the first table into a HiddenField on the FormView. It then takes the value from the HiddenField and attempts to insert it into the second table:
Dim hfDateRequestUpdated As HiddenField = FormView1.FindControl("hfDateRequestUpdated")
myDateRequestUpdated = hfDateRequestUpdated.Value
'... It then attempts to insert myDateRequestUpdated into the database.
[code].....
Is there any way to get the date (from Today.Date/User input) to a whole number and then return it to a date string?Only way I have so far thought of is:[code]
View 11 RepliesI am trying the following to select a long date, but becase the value is stored in SQL database as DateTime I am unable to return any results unless minutes and seconds match perfectly...I then tried to use 2 calendars and have the same issue with the DateTime format..
CODE:
The user will select an entry in a gridview, which then redirects them to a form that is populated with the data from the selected row (thus making the gridview editable in a more user friendly way). Null values are accepted by the DB and I would like to show null date values as blank (or " ") in the corresponding text boxes. Instead I get the error:
Conversion from type 'DBNull' to type 'Date' is not valid.
Here is my code:
'preceded by connection code
Dim sqlcmd As String = "SELECT * from Master WHERE RecNum = @recnum"
'Dim sqlCmd As New OleDb.OleDbCommand("SELECT * from Master WHERE RecNum = @recnum", connection)
Dim FileCommand3 As New OleDb.OleDbCommand(sqlcmd, connection)
[code]....
I doing a project for my office. In that I am showing the values and strings from a particular table based on the date range and vendor selection. It is working fine with the date range. Except within the date range if the particular reader has no data it throws an error message like dbnull string.
[Code]...
i am working in windows appl vb.net 08. And i am working in Access DataBase.I have one Table Called "Person" . In this "Person" Table one Column Name Called "OtherName". In this Column binded in one of the Combobox in a Form.But the Problem is "OtherName" Column having the Null Values.Before i bind this Column to Combobox i want to convert this NULL Values to String. Why i need the values in STRING means , In my code i using this Combobox as a filter in SQL Query.If i didn`t change the Null Value to STRING , The Combobox SelectedText or SelectedValue is Showing Nothing. So i am not able to get the Record.
Whn i write a Sql Query to Combobox and apply filter in WHERE statement like Combobox.Selectedtext or Combobox.SelectedValue In "Selected Change Committed Event" then i should get the record in the Output right but unfortunatly i am not getting the Record. The Record Count in DebugPrint showing 0.
[Code]...
In this application I need to allow users to enter a month as integer (1-12) then use integer tryparse to validate that input, that seems to be the easy part. I need two create two functions, one that returns the name of the month and the other returns the number of days in that month. The arrays are supposed to be defined and initialized within the function so that the main program can take the user input and call the two functions, then return the appropriate values as output to labels. I am not sure how to declare the arrays in their appropriate functions and then how to call those functions to retrieve the right value from the function.
View 1 Replieshow I can ensure that conversion of a date to a string and a string to a date will give me the same date format.
For example:
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim d As Date = Date.Now
[code].....
I'm actually only interested in the date part as the label text shows so f is more than I want.But also, the day and month are reversed.
Quick query...I'm trying to scan a long string and return any values that occur between the tags <FileName> and </FileName> I've got a bit of code here to use regular expressions to return the position of the occurunces of both substrings..Just wanted to find out if there is any way to scan for both substrings within one loop (as im currently doing 2, one for the first substring and one for the 2nd) so I can use something along these lines:
ringlist = Mid(XMLRESP, (startloc + 1), (endloc - 1))
MsgBox(ringlist)
to msg box the value between the substrings...either that or another approach to return the value between the 2 substrings (it can be of variable length)
Dim patternstart As String = "<FileName>"
Dim patternend As String = "</FileName>"
Dim matchesstart As MatchCollection = Regex.Matches(XMLRESP, patternstart)
[code].....
I need a function that would return true if the date provided was a payday or date of next few weeks paydays.Paydays are every 14 days on a Friday (not twice a month).I tried several attempts, but don't have a clue where to start, except that the function needs a reference date to calculate from. [code]
View 16 RepliesI'm trying the fetch only the date within the current and return how many rows Dim dc as new dataclassesdatacontext dim q=from p in dc.worktime where p.name.equals(session("name") and p.date ).count what I should I put after "p.date" ? And if I want to search for the record which there are record that are insert five days earlier, how to do that ? use (datetime.now - 5) ?
View 3 RepliesHow it's possible to get values (string) from the database when a user connects? i use in this
[Code]...
ve a simple vb code similar to the below,
Function getvalue (ByVal Val as double) As string
Dim Num as Integer
Dim Prd as double
[code].....
I am currently using a sql data reader (in vb.net) to extract an article object via a stored proc from a SQL Server 2008 database. Part of this object includes the two properties shown below:
theArticle.Truthfulness = ((myReader.GetInt32(myReader.GetOrdinal("Truthfulness"))))
theArticle.Relevance = ((myReader.GetInt32(myReader.GetOrdinal("Relevance"))))
My problem is that the Truthfulness and Relevance may return a null value and this is causing the function to fall over.I think I understand why. I am asking for an integer value (getin32) and because null is returned it fails.How do I accommodate the null value from the database so it does not fall over?
I'm having trouble figuring out what to do with the bolded part, when there are no nodes to return.If there are no image tags inside the <images> tag, i get an "Object reference is not set to an instance of an object".I have been searching and searching for an answer but can't find one.
Dim orders = From o In xmlLinq.Descendants("order")
Select New With { _
.orderID = o.Attribute("id").Value, _
[code].....
Title pretty much says it all. How do I format the date of a dateandtimepicker to insert it into the SQL date datatype?
View 20 Repliesi am retrieving data using data reader. Whenever a null value fetches from the column, the compiler encountering an error. The error occurs when column value contains NULL. I am using Visual Basic 2005.
Please look at the following error which is in red color:
DEVNA11.Checked = IIf(IsDBNull(dr("dev_serv_desc_final_na")), 0, dr("dev_serv_desc_final_na"))
txtPlanServDesFinal.Text = IIf(IsDate(dr("dev_serv_desc_final_planned")), Format(dr("dev_serv_desc_final_planned"), "dd/MM/yyy"), dr("dev_serv_desc_final_planned"))
System.ArgumentException: Argument 'Expression' is not a valid value.
Take the below example. I would expect the IsInterned method to return null, because this string can't possibly be in the intern pool having started up the test app for the first time? I would also expect, that if I did something like string.intern("this112233StringCan'tPossiblyBeInTheInternPool!£$%") first, then this would legitimately be returned by IsInterned from the pool. I've also done the same in c# and the behaviour is the same.
Whenever I use strings in code, I tend to do something like textbox.text = string.intern("someValue") etc or if (textbox.text = "someValue") etc. Infact, whever strings are being used, I've gotten in to the habbit of using string.intern. Is this a bad habbit rather than using constants or the resources file?
[Code]...
I want to retrieve total value from sales table in sqlcommand object. Below is my sample code.I will get error if there was no data in the tabel that matched my query saying that null could not be converted into decimal.
I would not get error if there was data that matched my query and returned the total value in tmpSales variable.My question is what is the best way to deal with this situation?
Dim CmdTmp As System.Data.SqlClient.SqlCommand
Dim tmpSales As Decimal
CmdSales = New System.Data.SqlClient.SqlCommand("SELECT SUM(Total) FROM Sales WHERE Date>= '1 Jan 2011' And Date<= '30 Jan 2011", ConDB)tmpSales = CmdSales.ExecuteScalar
I have a datetimepicker and combobox on my form. If a user does not change the date on dtpicker or does not change text on combo box, these controls return null value, and the save operation fails. The controls are bound to data in a database.
View 1 RepliesI'm making a data application and using the data adapters, I created a query in the designer:
EmpActivities_TableAdapter.InsertQuery(IdTextBox.Text, ActivityComboBox.Text, DescriptionTextBox.Text, Cdate(adddate.text))
The question is how can I set the adddate to null or nothing and save it? I'm using SQL server for the data.
How can i remove this in my crystal report . this value is showing if my date field in null . "1/1/1900 12:00:00 AM". I don't want to show thin is my report.I have two dates , case open date and case close date . if the case is not closed its showing this value so i want to remove this.I am using sqlsever.
View 3 RepliesThis video shows how to add validation for a textbox:[URL]..what about date ? I can't make it work for date.
View 2 RepliesI am working with calendar inside GridView using VB. I have some NULL date on the DDBB. I can fix the problem using EVAL, but when I try to save the date from the calendar, I got an error telling me that their is no @variable declared.[code]Everything is fine but I got: Must declare the scalar variable "@tDate" trying to save.This is beacuse I'm not using Bind, but with BIND I cannot run checkDate.
View 1 Repliesi have a datetimepicker with showcheckbox properties set to true..
when there is date in database, the checkbox is checked..
but when the database is null, the checkbox is unchecked..
here's the code:
Sub checkeddate() 'to set DateTimePicker.check (compare from database)
'if db is not null, then CheckBox is checked
If IsDBNull(DataSet.Tables("AssetMaster").Rows.Item(curPosition).Item(19)) = False Then
[Code]....
i have a date control on form (vb.net) and by default its value is current date. i want to make its value to null or empty so that no date is shown and user choose from the drop down date calendar.
View 9 RepliesFix my code I am trying to put null in sql server through a function that is excepting _dtSWO.
If I set _dtSWO = Nothing it returns #12:00:00 AM# which throws an exception. The field is nullable in sql server I just want it to return a blank[code]...
I am using visual studio 2010. I have a text box bound to a sql datetime field.I have to be able to either set or clear the text box. I can set it to any date fine, but when I try to clear it I am unable to save the record.i am using the binding navigator to save.
View 5 Replies