ADO.NET :: Query With Seemingly Ok Logic Not Working?
Jan 28, 2011
I am just a student so sorry if I sound amateurish. I am doing developemnt for a web application that uses LINQ to SQL (even though apparently its going to be depreciated soon) and this query always returns 0 results. I have lots of experience with LINQ to SQL and have applied it to the entirety of a huge site; this one query isn't working right though.
[Code]....
so I emailed myself stuff for debugging and sure enough, the parse to datetime and accesssing year worked fine, it grabbed 2010 from the db, month and day as correctly in the DB.the querystrings were in the URL and i verified that they are the values from which there would be many results
i have a table for customer forecast which contains customer, week number and quantit as columns. now i need to write query and list the week as column for each customer and each cell should have a quantity. how to write query for this using pivot logic. i dont want to use cursor.
I was wondering if setting a default value for a SelectList is considered to be presentation logic or business logic? For example, if a requirement is that an Employee cannot be saved without a Location, but 99% of the time the location that would be selected is a particular item -- say Atlanta. Because of this, the location SelectList should be defaulted to Atlanta when ever a entry screen for a new employee is displayed. Should I be defaulting the location in the model or in the view-model? One thing I realized is that the unit tests become awkward because in both cases, I'd be forced to test against a location that will always be present in production but I cannot create a unit test with my own test dataunless "Atlanta" was in the set of locations being used in the test.
I'm encountering a strange problem. Here is the scenario. I have built a query that accepts a parameter (WHERE LIKE clause).
I've tested this within the query builder and it returns exactly the number I would expect.
I then go back to my webpage and add the following controls:
Dropdown
Gridview
the user to make a selection from the dropdown. Postback on the dropdown is enabled so the page reloads and the Gridview displays the filtered results (via an objectdatasource). I've set the parameter to the dropdown control.
The trouble is when I run the page I make the selection in the dropdown no results are displayed. Even though the text displayed in the dropdown control is exactly the same as I inputted into the query builder when testing it.
I can get the current value of a URL query string by using Request.QueryString["UrlKey"], but can I actually modify the URL with code, without doing a form GET submission?
If the user is landing on the page for the first time, what is the easiest way to programmatically create the ?UrlKey=value through the Page_load method? Or am I better of doing this with Javascript or building a redirect Like: string redirect = "www.mysite.com?" + MyKey + "=" + MyValue;
Table User (UserID, Username) Table Admin (AdminID, Username) Table PM (PMID, SenderID, Sendertype, RecipientID, RecipientType) Get all Information from PM if SenderType == 'A' join SenderID to Admin-Table, get Username if SenderType == 'U' join SenderID to User-Table, get Username if RecipientType == 'A' join RecipientID to Admin-Table, get Username if RecipientType == 'U' join RecipientID to User-Table, Get Username
i have been having trouble trying to find out what is wrong with my sql select query... i wanted to select a sessionID by comparing the tourID and dates. the dates datatype at the database is datetime and the value of itemSessionDate is in string. i tried to convert itemSessionDate to date and dateAndTime but it gave me mm/dd/yyyy while the date in my database is dd/mm/yyyy hh:mm:ss. so i thought i can try using the itemSessionDate string as it has the same value as the one return from the database. but it keeps on goin to the if not reader.hasRows and quit the statement
I have a strange problem...I am programatically adding an SQL SELECT query to my SqlDataSource that my GridView is bound to. If I use the follwing statement it works fine:
[Code]....
But if I use the following one, the gridview fails to load. The only way that this is different is it uses RTRIM and CAST on one of the fields:
[Code]....
I don't understand why this can be. If I try the statement exactly how it is in the query builder and run it it returns the rows no problem.
I am trying to fill a gridview with the data from Product table selecting few columns . I am using 3 - tier architecture and in DAL getproduct(userid) I am writing the query but cannot figure out exactly how to get that working .. here is piece of method I wrote
I'm trying to create multi insert query in single stored procedure along with scope_identity variable. while execute the aspx page getting error "Procedure 'sp_seller_ins' expects parameter'@new1', which was not supplied." I have created stored procedure:
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_seller_ins] @txt_n_properity VARCHAR(50), @txt_t_properity VARCHAR(50), @txt_prop_for VARCHAR(50), @txt_flat_no VARCHAR(50), @txt_loc_country VARCHAR(50), @txt_loc_state VARCHAR(50), @txt_loc_district VARCHAR(50), @txt_loc_town VARCHAR(50), @txt_loc_area VARCHAR(50), @txt_loc_locality VARCHAR(50) AS BEGIN declare @new1 int declare @new2 int INSERT INTO dbo.sel_pro_details( nature_property, type_property, property_for, flat_no) VALUES ( @txt_n_properity, @txt_t_properity, @txt_prop_for, @txt_flat_no); set @new1 = scope_identity() INSERT INTO dbo.sel_loc_details( country, state, district, town, area, locality, pro_details_id) VALUES (@txt_loc_country, @txt_loc_state, @txt_loc_district, @txt_loc_town, @txt_loc_area, @txt_loc_locality, @new1); set @new2 = scope_identity() end code behind aspx page sqlconn mySql = new sqlconn(); mySql.CreateConn(); mySql.Command = mySql.Connection.CreateCommand(); mySql.Command.CommandType = System.Data.CommandType.StoredProcedure; mySql.Command.CommandText = "sp_seller_ins"; mySql.Command.Parameters.Add("@txt_n_properity", SqlDbType.VarChar); mySql.Command.Parameters["@txt_n_properity"].Value = txt_n_properity.Text; mySql.Command.Parameters.Add("@txt_t_properity", SqlDbType.VarChar); mySql.Command.Parameters["@txt_t_properity"].Value = txt_t_properity.Text; mySql.Command.Parameters.Add("@txt_prop_for", SqlDbType.VarChar); mySql.Command.Parameters["@txt_prop_for"].Value = txt_prop_for.Text; mySql.Command.Parameters.Add("@txt_flat_no", SqlDbType.VarChar); mySql.Command.Parameters["@txt_flat_no"].Value = txt_flat_no.Text; mySql.Command.Parameters.Add("@txt_loc_country", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_country"].Value = txt_loc_country.Text; mySql.Command.Parameters.Add("@txt_loc_state", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_state"].Value = txt_loc_state.Text; mySql.Command.Parameters.Add("@txt_loc_district", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_district"].Value = txt_loc_district.Text; mySql.Command.Parameters.Add("@txt_loc_town", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_town"].Value =txt_loc_town.Text; mySql.Command.Parameters.Add("@txt_loc_area", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_area"].Value =txt_loc_area.Text; mySql.Command.Parameters.Add("@txt_loc_locality", SqlDbType.VarChar); mySql.Command.Parameters["@txt_loc_locality"].Value =txt_loc_locality.Text; mySql.Command.ExecuteNonQuery(); mySql.Command.Dispose(); mySql.Connection.Close(); mySql.CloseConn();
I have a form that gets populated by LINQ and I want to be able to update the database using that same form. The form is populated by grabbing a querystring (for example, "edit=10") and searching the primary key for that record. So far so good. I have a button attached to the function below which is supposed to use LINQ to update the database with data from the form. I get no errors, but for some reason, it is only updating one field (Last_Updated) instead of all of them.
i am trying to display the values of a stored query i have created in an access database. the stored query uses a number of other stored queries to calculate the results. Everything was working fine until i used the dconcat function of access in order to concatenate the values coming from some records.
The strange part is that access is working correctly providing the correct results for the query while when trying to execute the new stored query on asp.net i get an "Undefined function 'DConcat' in expression" error. i know that my query is working correctly since i get the right results every time i execute it in access but i get the problem described above when i try to get the results through an asp.net web page i have created.
I've got a C# MVC 2 application using EF 4. My DAL project gets data from the Model, translates them into POCO's and returns ViewModels to the BLL which is called from the controllers.I've set up validation attributes on the POCO classes and that works for "Required" fields etc. I would like to add business logic such as "From" has to be before the "To" date. Can this be done on the POCO classes so it is automatically validated client-side in the view?
Also, I would like to add some functionality to the BLL layer such as checking if a resource is already booked between the From and To dates to avoid double bookings. This should fire before the ViewModel is saved. I tried a Try/Catch statement in the controller so that I can throw an error in the BLL, but I don't understand how to return this error to the view with an appropriate error message added.
I need to assign channel for each schedule. There can be as many concurrent events as number of channels allocated for the customer. I.e if the customer is allocated 3 channels then he can have 3 concurrent events. If a channel was allocated to a event then the same channel cannot to allocated to another event that falls under same time but the same channel can be allocate to another event if the time differs.
I've a MDX Query that has where clause as shown below.I'm designing report using SSRS 2008. How can i pass date as parameter? I tried to setup @from and @to as parameter but not working?
WHERE ( {[Date Central].[Calendar Date].[2010-04-01 00:00:00]:[Date Central].[Calendar Date].[2010-08-30 00:00:00]} )
need it to work as WHERE ( {[Date Central].[Calendar Date].[@From]:[Date Central].[Calendar Date].[@To]} )
i have a requirement that i need to download xml file from ftp and store it in a local folder and i have to read the xml and store it in my database. So i need to read the xml file and insert into database as bulk way. not instant insert. so which would the best way?
Does anybody know how to implement this new feature of the MVC 2 RC?
Here is verbatim what ASP.NET MVC 2 Release Candidate Release Notes says:
"...Buttons in a form can specify that they do not cause validation logic to run. The default is that every button in a form causes validation logic to run, and if validation fails, the validation logic blocks submission of the form. Enabling validation selectively for buttons lets you create forms .
have gone through many post but unable to identify how IsPostback peroperty of page works.HTTP is a stateless protocol so how server identify that a client is making request 2nd time not 1st time and set the value for IsPostBack Peoprty.
As I am learning and working on Asp.Net MVC application, I want to know that what is the better place to write Business Logic and Data Access logic in MVC.Where should I write DataAccess and Business Logic among three layers (Model, View and Controller) ??Could anybody please tell me the correct way to write the code for this.Scenario: I want to retrieve all the employees where employee name like 'Mi%' ( I have SQL procedure to execute and retrieve the data.)PS: Want to know that where I should create instance of Business Logic class and where I should create instance of Data Access layers class?