I am implementing an online parking reservation system and I need to bind a table with 2 Controls.
for example the user selects a Reservation start date and the parking location from a RadioButtonList and then a button (Search Availability) is pushed to fetch the parking from the database according to the Date selected and Location.
the question is: How can I bind the (Reservation Start Date Control) with (RadioButtonList) to both search in the database? and what would be the Sql Query?
Regards.
This is pretty basic stuff so you've got a lot of work ahead of you.
On your aspx page, you will want to use a SqlDataSource and add two ControlParameters to the SelectParameters, one for the RadioButtonList, one for the TextBox/Calendar with the date. Then create a GridView control to display the results and set the DataSource of the gridview to be the SqlDataSource.
Depending on your database schema, the SQL Statement will look something like this:
SELECT * FROM [Parking] WHERE [LotID] = #LotID AND [Date] = #Date AND [Reserved] = FALSE;
However, I have done reservation systems in the past, and queries to find available spots for a particular day are rarely simple. I would suggest worrying about writing the SQL query first and then getting the web page to run the query later. If you post information about your table schema and tag it as a SQL question you'll probably have better luck.
Hope this helps.
Related
I have a table with dates in mysql that I want to populate a vb calendar with as events, or "active" days.
Using a sql statement with something like
Select event, date FROM dateTable WHERE event = eventType.SelectedValue
how do I put these as events on my calender
<asp:Calendar runat="server" id="calendar1"></asp:calendar>
I'm sure I use data:repeater in some way I just can't figure it out.
Here's MSDN's article on Displaying Selected Dates From a Database in the Calendar Control.
The modifications you'd need are:
swapping out the SQL Server (System.Data.SqlClient)code with the MySQL Connector for .NET (or your favorite MySQL library for .NET).
suggested improvements might be scrapping the DataSet, and go with a local MySqlDataReader instead
My goal is to load a row from db to a webform and let the user update it's value .
The user searches an id (i have a stored procedure for that), how i show that data from the
row nicely in the web page through the dal layer. After the data is shown on the page the user need to update a cell in the row and send it.(the part of updating is not the problem).
in other questions how should the dal method should look and how i integrate it's result in the presentation layer (the aspx webform).
thanks a lot.
p.s.
I've done a little reading but i don't know what exactly to use data object, data row , data table, object data source. i'm little confused by the data bind alternatives.
You have several options and one of them is using ObjectDataSource.
If it is going to be a single record you can use DetailsView or Formview else you use GridView.
Check the tutorials here:
Displaying Data with ObjectDataSource
Data Access Tutorials
I'm coding a report page. In this page, there are two date fields for user to filter the date and the GridView is filled depending on these dates in the CodeBehind (When user click the button view). Now I want to implement a paging/sorting feature for this GridView. I've researched and see there are default paging for GridView which is not very efficient (my report table may have thousands of records) and custom paging but this requires using ObjectDataSource (which I don't use). Thus anyone can recommend me some approaches that are best used in this situation? Some tutorials will be gladly appreciated :)
Thanks,
Assuming you have the records stored in a database, I would get the record count and use that number for paging. Then I'd query for the ones I want to see on each page.
string.Format(#"
SELECT TOP {0} * FROM Records WHERE pkId NOT IN (
SELECT TOP {1} pkId FROM Records ORDER BY pkId
) ORDER BY pkId;",
upperBoundary,
lowerBoundary
);
Where upperBoundary would be lowerBoundary + itemsPerPage, for example. Using MSSQL, we don't have the luxury of MySQL's LIMIT feature, but this does the same.
Narrowing down on dates, would be something like
SELECT * FROM Records WHERE Date > earlyDate AND Date <= lateDate
This is the most effecient way in my oppinion, cause it causes little traffic and if you cache the record count, you won't have many queries flying around either.
I have a table in ms-sql
obm_FeeTable
FeeId int,
FranchieId int,
Amount Money,
ChequeNo int,
BankName nvarchar(200),
PaymentDate DateTime
when I want to display all collection in crystal report it don't show Amount / PaymentDate
when creating report, don't know why its doing like this.
Please help why is it doing like this. also how to use linq with Crystal Report.
Thanks
To get fields to show up in Crystal's data connection, I often have to go to Database->Set Datasource location and then re-select the same table/view/stored proc I am using. Click the name of your table/view/Stored Proc in both the top and bottom windows. This tells CR to "change" the datasource from the old one (without new fields) to the new one (with new fields) even though they are the same view/table/proc. Then click update. This will reconnect your report with the same datasource, but will pick up any of the changes (new fields) in said datasource.
Yes, you can use LINQ with Crystal, it doesn't matter as long as the data you pull with LINQ ends up as something Crystal can understand. It needs to be stored in a DataSet or DataTable that Crystal can understand (you need to set the reportdatasource to your DS or DT, and it works great.
Have you recently modified the table to add these fields? If so, perhaps Crystal doesn't know about them yet. To fix this, right-click inside the report, select "Database" -> "Log On or Off Server...". OPen The "Current Connections" item and select the one where your table lives. Click the "Log Off" button and then the "Log On" button. This will refresh Crystal's view of the database objects, and you missing fields should appear.
Another possibility is that the login you are using to access the table doesn't have 'select' permission on thos columns.
I don't think linq is applicable to Crystal, but the is a very different question. You should probably post it separately with more detail on what you want to do.
I'm building a heavily CRUD based ASP.NET website and I've got to the phase of the project where I'm trying to build a search webpage that shows the user different subsets of a certain important table based on parameters they enter such as dates and different text fields.
I can't use a fixed SQL statement, because depending on whether they search by date or by something else, the SQL would be different, so instead I have been generating a results list using a table web control that starts out invisible and then is filled and set to visible once the user identifies a search they want to make. I used a table control because its easy to create and modify in the code behind, and I was able to make the needed calls to the database and populate that table as required.
However, the second thing I need with this search page, is the ability to allow the user to select a record from the results and then go edit it using the rest of the CRUD based pages on the site. To do that, I created asp:buttons in the table and gave them all different ids and the same event handler. But since I created the buttons dynamically, it seems the event disappears on callback and my scheme fails, so I'm taking a second look at how to do this.
My current code for the events looks like:
tempcell = new TableCell();
Button tempbutton = new Button();
tempbutton.Text = "Go";
tempbutton.ID = "gobutton" + rowN;
tempbutton.Visible = true;
tempbutton.Click += new EventHandler(tempbutton_Click);
tempcell.Controls.Add(tempbutton);
temprow.Cells.Add(tempcell);
My results table is declared like this:
<asp:Table ID="ResultTable" visible="false" runat="server"
GridLines="Both" CellSpacing="8">
</asp:Table>
I'd like to be able to identify which record the user selected, so I can send that info on to another page. And of course, I still need to be able to generate results for several different search criteria. Currently I have date, template and code based searches that lead to different stored procedures and different parameters based on what the user has entered.
Any suggestions on this? It seems like the data grids and repeaters require SQL statements in advance to work properly, so I'm not sure how to use them, but if I could then the item command approach would work with the buttons.
Your event will hook up successfully if the button is recreated in the page load event.
Otherwise, use a GridView. It is the perfect solution for simple CRUD, and you can control it as much as you need.