DataSource Controls :: Set Field As DBNull.Value If Field Is Blank?
Apr 7, 2010
I have a 20 to 30 fields on a form. Most of them are optional. However, the users can fill out what they want. If a user dosen't fill in a field when data is sent to the database it's sent as blank, instead of NULL. Is there a way I can generically say "for all textboxes if Equals("") then DBNull.Value". Without going through each and every textbox?
View 2 Replies
Similar Messages:
Aug 12, 2010
My database includes a table with sever filds which are defined as (varchar(1),null), I tried using DBNull.Value, null, ' ' but cannot get a null inserted in that field of the database,
[Code]....
View 4 Replies
Mar 3, 2010
I wanna join all the field as a new col.
but how can i ignore the empty field because i always join the field and separate by space like the following.
select (field_1+' '+field_2+' '+field_3) as new_col from TABLEA
but if the field is empty, then there is the double space
how can i ensure all the space is one space only.
View 2 Replies
Feb 21, 2011
is both same
View 1 Replies
Feb 21, 2011
I want to return all rows from a SQL Server 2008 database table into a SQL data source if a textBox field is blank. So I made a stored procedure with an if @date IS NULL clause.
Although the stored procedure seems to be working fine in Visual Studio 2008 the actual webpage displays no results.
I am guessing I have to send a DBNull value to the stored proc if textBox.Text == string.Empty. I tried the SqlDataSource1.SelectParameters.Add but it seems that I get a conversion error from DBNull.Value to string.
Is this the source of my problems or am I missing something else? How would I pass DBNull.Value to a stored proc if a textfield is blank?
View 2 Replies
Jan 18, 2011
I have a field of type smalldatetime in a sql table. through a webform, i am trying to insert a blank value(i.e. through A blank text box) but its showing an error that the" value can not be recognized as valid date time". I am using a textbox to insert value to this field. but that text box can also be blank sometimes. plz help.
View 4 Replies
Jun 21, 2010
is there a way in crystal report to remove blank space between two data field for example
Field 1 Field 2
how do i make it the distance between Field 1 and Field 2 become closer and look like this
Field 1 Field 2
without changing the position of the Field 2 in the report design... i need this cause the data in Field 1 is different for each user and i need the Field 2 to have a smaller font size than the Field 2 so i cant use formula since formula only allow 1 font size.
View 5 Replies
Feb 1, 2010
if i select a blank field and then insert to the drowdownlist in repeater.
how can i display the text of the blank field but the insert val is empty.
SQL as below:
select '' as Field_1 union select field_1 from table.
i would like to set the value to blank and display text to "please enter".
View 3 Replies
Apr 22, 2010
I am using a GridView Control to display multiple fileds with 0's and 1's.
I am using template fields where CheckBoxes are used.
Where exactly and how do I apply the Logic to get a checked CheckBox when field Value=1 and unchecked CheckBox when field Value=2 .Also some times to be able to write a YES where fieldValue=1 or NO where filedValue=0
Do I apply this logic using asp or C#? How?
View 2 Replies
Jul 9, 2010
I have 2 fields in my gridview one called ScriptType the other BagNo, when a user click the edit button, I would like the BagNo filed to be disabled if the ScriptType field is = "TTA" and enabled otherwise. How can I do this?..something along these lines see below..I am using VB..
[code]...
View 14 Replies
Apr 1, 2011
I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to a table in my Sql Server database. I wanted to add an initial value to the DropdownList
namely "- select -" .
I set the AppendDataBoundItems property to true and added the initial value as a ListItem.Markup of the DropdownList
<asp:DropDownList ID="DropDownList_HP" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_HP" [code]...
This works fine for new input. The problem is however that the database already has records that were entered through a Windows Application and many of these records has a null value in this field and exceptions are thrown when I tried to open these records
and the system tried to set the SelectedValue of the DropdownList.After some more searching I found this help
http://msdn.microsoft.com/en-us/library/ms366709.aspx
So I changed the ListItem in the DropDownList markup to the following:
<asp:DropDownList ID="DropDownList_RefHospDV4" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_RefHosp" [code]...
This now solved the problem of opening a record where the value is null in the database, BUT now the RequiredFieldValidator is not validating anymore to make sure that a databound item is selected for this field and not the initial value "- select -". So basically now it is not checking anymore to see if valid input has been entered for the DropDownList and it accepts "- select -" thus it acts as if the field is not a required field anymore.
In short what is required is that I want to make sure that the user enters a valid selection in the DropDownList, but it must also cater for old records that do not have this field entered yet so that those old records can be opened in the DetailsView .Opening Old records (with null in that field):When these old records are opened in the DetailsView the DropDownlist should show "- select -" when the value in the database is null.
Saving records (old or new records):When saving the record in Insert mode or Update mode the RequiredFieldValidator should show that a valid input is not selected if the DropDownList is still on "- select -".
View 1 Replies
Dec 19, 2010
I have a grid view, and I add new column as a hyper link field, I want the navigationURL for this field to be Pageexample.aspx?ID=other field value like this
[code]...
is that possible ?
View 2 Replies
Oct 27, 2010
I have a table in sql having a numeric data type column,Now i want that whenever user left this field blank from front end aspx page, null value should be inserted in this column from stored proc.How can i achieve this? Also what kind of data type is most appropriate on front end for such taking kind of value?
View 2 Replies
Jul 31, 2013
i am implementing a update query module.i am displaying all fields from a table for a term searched. well now i am implementing update option for the record which are displayed, i have like 70 columns in my table, and i want to know how to restrict some selected fields to be only read only while the form can be updated ?Like if user select to update a record then some selected field such as "Timestamp, UID etc some selected fields" remains READ ONLY !
View 1 Replies
Mar 14, 2011
I am facing problem in my update statement,
Dim abc As String
abc = Request.QueryString("str")
Dim userName As String = CStr(Session("user"))
Label2.Text = userName
Dim MyConnection As New OdbcConnection(ConnStr)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
If MyCommand.CommandText = "Select userid from week where userid ='" & userName & "'" Then
MyCommand.CommandText = "Update week Set value = '" & abc & "' where userid ='" & userName & "'"
Else
MyCommand.CommandText = "INSERT INTO week (value, userid) VALUES('" & abc & "','" & userName & "')"
End If
MyCommand.ExecuteNonQuery()
MyConnection.Close()
View 18 Replies
Jan 24, 2010
I have field_1, the data format store in the field is about "Mary, Amy, Billy, Ma"
how can i extract the record that the field_1 has Mary.
I can't use the like'%Mary%' because it can extract 'Ma' too.
I would like to extract exactly Mary. or can i split the field_1 by ',' in sql?
View 3 Replies
Jan 22, 2011
I used sqldatasouce and storeprocedure to populate DetailView. I need update few tables by pass parameters to my storeprocedure. but some value always lost (most of them is keyfield). when I checked those value through sqldatasource_updating event they are null . How can I get the correct value?
<asp:ControlParameter ControlID="DropDownList1" Name="Fname"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList2" Name="Lname"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="eid" Type="Int32" /> <--? why become null
<asp:Parameter Name="Fname" Type="String" />
<asp:Parameter Name="Lname" Type="String" />
<asp:Parameter Name="Room" Type="String" />
<asp:Parameter Name="Active" Type="String" />
<asp:Parameter Name="bid" Type="Int32" />
<asp:Parameter Name="bname" Type="String" />
<asp:Parameter Name="vid" Type="Int32" />
</UpdateParameters>
View 4 Replies
Jan 14, 2011
At the top of my form I have some code that calculates a field
[Code]....
In my form I have this code. What changes below do I need to make to have the value of Date in XXXX?
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlConnection %>"
SelectCommand="SELECT NumPeople, Date1,Time1,Venue FROM People_Count WHERE ((Date1=@ArvDate and Time1 >= '06:00:00.000') or (Date1=XXXX and Time1 <= '06:00:00.000')) and Venue='F & B' ORDER BY Date1 ASC, Time1 ASC">
<SelectParameters>
<asp:QueryStringParameter Name="ArvDate" QueryStringField="ArvDate" />
</SelectParameters>
</asp:SqlDataSource>
View 2 Replies
Mar 26, 2010
is there some language to add to SQL that will hide a field?
View 5 Replies
Mar 27, 2010
I have the code below that works fine, but I need to have more than one field using the same command.
[Code]....
View 5 Replies
Apr 13, 2010
Once again, I find myself stuck!
I am attempting to compare one of ASP.NET's membership userID's with the current userID in an SQL query, however because of the "hyphens -" in the uniqueidentifier field type of userID, i am unable to compare the ids. is there a way around this? (in my example, family_id from tblFamily is the userID that has type uniqueidentifier). my code as it stands is:
Dim UserID As String = New String(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString())
Response.Write(UserID)
Dim strConn As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
Dim SQLI As New Data.SqlClient.SqlCommand("SELECT family_name FROM tblFamily WHERE [family_id] IS " & UserID & "")
Dim sqlCon As New Data.SqlClient.SqlConnection(strConn)
sqlCon.Open()
SQLI.Connection = sqlCon
Dim RSI As Data.SqlClient.SqlDataReader = SQLI.ExecuteReader()
RSI.Read()
Dim FamilyName As String = "0"
While RSI.Read
FamilyName = Convert.ToString(RSI("family_name"))
End While
Response.Write(FamilyName)
RSI.Close()
sqlCon.Close()
View 6 Replies
Nov 19, 2010
I have a form that submits one entry to a 'Listings' table and multiple entries to a 'ListingLocation' table depending on how many cities the user selected. When the listing is created, I need the auto generated 'id' field to input into each of the the listing rows of the 'ListingLocation' table. This seems like it should be simple but I cannot figure it out. I currently have it hardcoded to enter '22' where I need it to enter the listing id.
<script runat="server">
View 3 Replies
May 17, 2010
What is the best practice regarding an integer primary key that reach it's maximum possible value at some point of time?
Is there any standard action that needs to be taken so such a situation is never reached?
This is a very practical problem, and I am sure many people out there must have addressed it already.
View 2 Replies
May 18, 2010
I have a table in which a field consists of a multiple values like CSE, INF, ECE etc., I want to take only one value from the field like
When an user selects a particular branch like CSE, the user should get the list of Colleges assosiated with the branch CSE. How to do this?
View 3 Replies
Jan 3, 2010
For example: INSERT INTO table (col1, col2, col3) VALUES ('value1','value2,'value3')But I would only like to insert the row if value3 isnt already present in col3 in some previous row. What is the best way to do that?And the insert command is run 50+ times in a loop (with different values each time for value3)
View 4 Replies