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
Related
I've written an SQL Server stored procedure that, amongst other things, accepts a date parameter:
CREATE PROCEDURE data.addScore
... (some parameters),
#testDate date
AS
On an ASP.NET page I have a textbox with a Calender Extender control (from the AJAX Toolkit) that allows the user to select a date; the date is stored in the textbox in the format DD/MM/YYYY. I have some code that is supposed to execute the stored procedure with the parameters, using the date value from the textbox:
cmd.Parameters["#testDate"].Value = Convert.ToDateTime(((TextBox)li.FindControl("date")).Text);
I know I can definitely get to the textbox's value using ((TextBox)li.FindControl("date")).Text, but for the life of me I can't get it into a format that doesn't throw up one of a few errors, mainly 'Input string was not in the correct format'.
When I run the stored procedure directly on the server I usually bind the parameter like #testDate = 'YYYYMMDD'.
I would suggest you don't store anything in the textbox using regional, ambiguous formats like dd/mm/yyyy. If you use an unambiguous format like YYYYMMDD, you're not going to have any issues. And if users are picking from a calendar control or something, it should be easy to separate the date you present to them from the date you pass to the database.
<asp:Textbox id="date" runat="Server"></asp:Textbox>
<cc1:CalendarExtender ID="calwhendate" runat="server" Enabled="true" Format="YYYYMMDD"
TargetControlID="date"></cc1:CalendarExtender>
Change your Ajax Calendar Control to your desired format
I have a GV and a DV that extract data from the same database. The link between these controls is when a record in the GV is selected, the DV displays more details about that record.
Do I need separate connections? Obviously, I haven't achieved this goal and am working on it. Thanks.
CLARIFICATION so as not to waste your time:
I am asking about connection, not datasource. The reason that I am not sure the same connection can be used is that with GV, the connection doesn't have any parameter. Whereas with the DV, it needs the record ID passed to it. Or am I wrong?
Here's the link to code on the net that makes me wonder:
http://asp.dotnetheaven.com/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetails.src
I am a novice so am still confused with the terminology. Thanks for being patient.
They can use the same datasource. (Such as an ObjectDataSource or SQLDataSource)
You can use the same data source, i.e. a DataTable. But when the Gridview row is selected you will need to find the index of the selected row and then find the DataRow from the DataTable and rebind your DetailView to that DataRow. Hope this helps.
I think that you are using Visual Studio databinding, and I would say that same Connection(DataSource) object can be used (if that is the way it goes), but I would rather suggest you avoid this design time Visual Studio programming, although it is simple and fast
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.
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.