DataSource Controls :: Sql Query / Remove The Timepart In The GetDate ()?
May 17, 2010
whats wrong with this SQL.
select a.Del_Date,a.Deliverables,
b.Cost_Code, c.UserName, c.Email
from mtblDeliverables a
join mtblContract_New b on a.Cost_Code
= b.Cost_Code
Join mtblUser c on b.Proj_Lead
= c.UserName
where a.Del_Date
= DateAdd(dAY, 10,
GetDate ());
This will show me all records which has a Del_Date = GetDate()+10 days.My data in the SQL is stored in datetime format.When i execute this, no records are shown. Is this because of the time part in the GetDate(). how to remove the timepart in the GetDate ().
I have selectCommand="SELECT EID, ... WHERE (EDATE >= GETDATE())"
But its not showing the record for today's date. Why is that? I can do that whith ([EDATE] > DateAdd(day, -1,GetDate())) but was wondering what is that I am doing wrong!?
1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.
Dim MediaQuery = From m In dB.DOWNLOADS _Where m.ID = id _Select
which returns a record from the database. One of the fields in the record is a FK to another table. I need to read this value to be able to set a dropdown based on the ID but I can't work out how to access it. For a standard record I can just do the following txtTitle.Text = MediaQuery.FirstOrDefault().TITLE
However with the foreign key it doesn't work like that. I've tried drpGroup.SelectedIndex = MediaQuery.FirstOrDefault().DOWNLOAD_GROUPS.ID where DOWNLOAD_GROUPS is the FK field but it returns Object reference not set to an instance of an object. If you're simply wanting to read some values from a single db record in the entitiy framework and one is a foreign key how should I go about getting the value?
Using Microsoft Visual Web Developer 2010, I have created a SQL database, with the goal being to create a Lead Management system for my company. I have created two columns: 1 is named InitialCall, and the other is named FollowUp. The InitialCall column has a datatype of "datetime", and currently, the default value setting is (getdate()). The FollowUp column is set to varchar(max), because I want to allow a sales rep to add whatever information they want to.
What I would like to do is change the default value setting in InitialCall from (getdate()), so that it will update that field whenever a sales rep upates the FollowUp field. In essence, this would create a time stamp so that I would know the date and time that the sales rep followed up with a particular lead. What would I enter the default value as?
how can i find the value in the field which contain "," and remove it in sql e.g:
the field is: 11,12,13 how can i find 12 and remove it becomes=> 11,13 if the field is 12,13,14==> 13,14 if the field is 9,10,11,12 ==> 9,10,11 if the field is 12 only ,then result is empty
I'm trying to remove extraneous characters like quotes, commas, etc from my dataset. I get the fact in the standard way of doing things in your code behind you simply go
string data = data.replace(",",""); or something like this. However, a datasource doesn't seem to give me that capability. What can I do to make it do this? I'm importing data from an excel sheet into a gridview. The commas are goofing up my view. I'd like to replace any commas in the dataset with spaces. Here is the code I have.
removing duplicate rows from datatable or (dataset) by columnd ID (unique). Below function is working but I would like to edit/adjust the remaing (former) duplicate row's value, not the ID value btw.
Example:
ID name sport ------------------------------- 356 John Football 357 Johny Hockey 357 Johny Hockey 358 mike Soccer
should be:
ID name sport -------------------------------------------------------------- 356 John Football 357 Johny newFoo Hockey 358 mike Soccer
Public Function RemoveDuplicateRows(ByVal dTable As DataTable, ByVal colName As String) As DataTable
Dim hTable As New Hashtable() Dim duplicateList As New ArrayList() For Each drow__1 As DataRow In dTable.Rows If hTable.Contains(drow__1(colName)) Then duplicateList.Add(drow__1) Else hTable.Add(drow__1(colName), String.Empty) End If Next For Each dRow__2 As DataRow In duplicateList dTable.Rows.Remove(dRow__2) Next Return dTable End Function
I have a Document name column with varbinary(max) type column in my table
first time when i upload document i am storing doc as a byte array
Dim fs As Stream = Me.fileupload1.PostedFile.InputStream Dim br As New BinaryReader(fs) Dim bytes As Byte() = br.ReadBytes(fs.Length)
in my application i have remove atttachmentDoc button, i want to remove uploaded doc from db
so when i pass like this to my storedprocedue
Dim obj As New cls1 Dim bData() As Byte = New Byte(0) {} bData=nothing With obj Dim dt As DataTable = Read_Doc() If dt.Rows.Count > 0 Then If Not IsDBNull(dt.Rows(0)("Document")) Then .Document = bData .Document_extension = "" .Remove_Attachment(Me.Selected_ID) End If End If End With
i got error
dbAccess.executeQuery: Procedure or function 'SP_DML1' expects parameter '@Document', which was not supplied.
I use an objectdatasource programmatically to use a parameterless method when SearchWord variable is empty and a Search method with one parameter when SearchWord is not empty, the event I use is objectdatasource selecting so that I can adjust parameters conveniently, I have a problem here: I can add a new parameter and set its value but I can't remove a previously added parameter from objectdatasource selectparameters and an error raises because of this, this is the selecting method:
[Code]....
Both adding and removing the search parameter takes place in this method while adding works removing the added one Not works.
{"Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition."}
view on browser application
Line 33: Line 34: GridView1.DataSource = dtLine 35: GridView1.DataBind()Line 36: End SubLine 37:
This is an my vb code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Me.IsPostBack Then Me.BindGrid() End If End Sub Private Sub BindGrid()
I have a database table field named User_Created_Date of type Varchar.I want to write a query to fetch all records where the difference between Today's date and User_Created_Date is greater than 31 days
I have a sql server table with a date column that has a default value of GetDate()
this default does not seem to get passed to the EF and so i was wondering what the most elegant way was to code this default value within my asp.net application? I dont want to manually alter the EF Model as i may want to re-import it and dont want to lose these changes.
I dont know if this is possible or not, but I have a column that I need to remove a bunch of exponent superscript references from a html field (and leave the rest). Does anyone know how to do this with SQL?