DataSource Controls :: Hiding Field In SQL?
Mar 26, 2010is there some language to add to SQL that will hide a field?
View 5 Repliesis there some language to add to SQL that will hide a field?
View 5 RepliesI need to be able to check programatically if a SqlDataSource contains no rows, and make a Placeholder visible if it does contain rows, and invisible if it doesn't. I seem to be able to return the affected rows using SqlDataSource1_Selected, but turning the placeholder invisible never works.
turning the placeholder off and on depending on whether the data source contains rows?
I am using a gridview where i have a table kind of structure inside each gridview row. Inside that table i am having various labels and corresponding values in front of them. Now i want to hide the label itself when the corresponding value is not fetched(or is null) from the database.
View 2 RepliesI 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.
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 RepliesI am hiding a TextBoxin my aspx page like this: myField.visible=false; Now I have a DropDown as well which tries to access the TextBox on IndexChange. The problem is, it cant access the hiffen TextBox and I am getting document.form[0] is Null or Not an Object. How can I solve that? Is the some check for that in JavaScript?
View 1 RepliesI 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()
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?
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>
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>
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()
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">
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.
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?
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 Repliesi need to update one field in a tabel just to +2 and i can not find out how to do it the code i have write until now is just to find the field i has to update this i the code
[Code]....
write the last code there can +2 to a.point field in my db
I have a table "Table1" which has mani 3 fields ID: int,
Date1: datetime,
Date2: datetime
All fields are filled except Date2, so I want to copy the records in Date1 to Date2I tried this query, but it didn't work
[Code]....
I have a field that may or may not contain comma.
if the field contain some word and separated by comma
how can i remove specific word in the field.
e.g. the field contain --> 11,12,13
how can i remove the number 12 and remain 11,13 in the field?
I am using:
href='<%# Eval("Directory")+eval("Agenda")%>
to provide a link to documents held in directory so directory contains [URL] or [URL] Agenda contains
00209-FebruaryMtgMin%5E_.pdf
If I declare Directory as VarChar(nnn) where nnn is large enough to accomodate the longer field, The statement <%# Eval("Directory")+eval("Agenda")%> returns
[URL]self.aspx/.Public/ 00209-FebruaryMtgMin%5E_.pdf
How can I get rid of the Pad characters?
I'm trying to get an IDENTITY column to auto-increment with each new row inserted, so that the field (userid in this case) can be used as a unique identifier.
However, I'm getting this error:
[Code]....
My code looks like this:
[Code]....
I don't understand - if I have to explicitly insert something into my auto-increment column, how do I know what to insert? Isn't the point of an auto-increment column that it's... auto?
I want to add a field in a Existing table.
I dont want to alter the whole table.
Give me Solution at the Design side.
I have a gridview which shows a list of data... at the end of each item I have added a button which is linked to the onclick event... when a button is clicked I want a value to update on that specific row... but I can't get it to work :( my code is below...
SqlDataSource 1 code...
UpdateCommand="UPDATE [PurchaseProduct] SET [BDConfirmSent] = 'Yes' Where [Id] = @Id">
<UpdateParameters>
<asp:Parameter Name="Id" />
<asp:Parameter Name="BDConfirmSent" />
</UpdateParameters>
Code Behind...
Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating
e.Command.Parameters("@BDConfirmSent").Value = "Yes"
End Sub
Protected Sub Button1_Click()
SqlDataSource1.Update()
End Sub
When I click the button it just postsback the page but then the [BDConfirmSent] field is still empty instead of being "Yes"
how to get my perclock field to show a decimal? For some reason I keep getting '0'.
View 3 RepliesI want to store value like 01,02,03 in database but whenver i do so the database transfor those figures into 1,2,3. The field is Int Type.
View 4 RepliesI am trying to get all records 7 days from the Purchase date field using this query:
SELECT DATEADD(dd, 7, dtPurchaseDate) FROM CustomerProduct
This doesn't seem to work because it is giving me dates from 2002, 2003, etc. What am I doing wrong.