|
You're probably going to need two calendars - one to identify the start date and one to identify the end date. Once the user has chosen the dates (make sure that the before isn't after the end date), issue a query to the database selecting values between the two dates. As you have given us no other information to go on, this is as close to an answer as you are going to get.
|
|
|
|
|
sir i solve this problem
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" EnableScriptGlobalization="true"
EnableScriptLocalization="true" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy"
PopupButtonID="txtDate2" TargetControlID="txtDate2" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
PopupButtonID="txtDate1" TargetControlID="txtDate1" />
Enter From date <asp:TextBox ID="txtDate1" runat="server"></asp:TextBox><br />
Enter To date <asp:TextBox ID="txtDate2" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" /><br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
Server side
using System.Data.SqlClient;
using System.Data;
public partial class AJ2Cal : System.Web.UI.Page
{
SqlConnection sqlcon = new SqlConnection(@"Server=RAVI-PC\SQLEXPRESS;database=test;uid=xxxxn;pwd=yyyy");
SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
sqlcon.Open();
sqlcmd=new SqlCommand("select * from empdt where dte between '" + txtDate1.Text + "' and '" + txtDate2.Text + "'",sqlcon);
da=new SqlDataAdapter(sqlcmd);
da.Fill(dt);
if (dt.Rows.Count>0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
sqlcon.Close();
}
}
|
|
|
|
|
Please don't concatonate SQL Strings this will leave you open to SQL Injection. Read up on Parameterised Queries.
C# Parameterised Queires[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Please also explain the problems with selecting "all", as opposed to what you need. And that the empty event should be removed. And why we dispose things. And..
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
And also the unnecessary use of global variables, when they could more than likely be better at method level? so I also add that to my list .
For me the concatinated SQL String just jumped straight out at me.
but to your question I would suggest the OP also have a read of this Is using COUNT(*) or SELECT * a good idea?[^] The first answer is a good read.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Simon_Whale wrote: For me the concatinated SQL String just jumped straight out at me. It does, but that doesn't justify a hit-and-run post
Simon_Whale wrote: The first answer is a good read. COUNTing all records is not a column-wise operation - it won't be pulling a large blob that has been added last month from the db that travels over the network.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Generally it is expected that you include the exact problem and what you have done so far to solve it.
It's good that you state what you want to achieve, but without more information the answer could possibly be too extensive to write down.
|
|
|
|
|
Image stabilization software required for long range camera (Camera range is 20 KM)into existing Video Management Software developed in C# .net
|
|
|
|
|
So, what have you tried? What code have you put in place? What are you stuck on?
|
|
|
|
|
Trying to learn LinqToSQL... I have this query working in SQL...
Table1 = 0,1,2,3,4 (enum table)
Table2 = abc 0 data
abc 2 data
abc 3 data
def 1 data
def 2 data
so Table1 is an enum table. Table2 contains the data. For state 'abc' for example, I have data defined for levels 0,2,3. For state 'def' I have data defined for levels 1,2.
What I want is:
abc 0 data
abc 1 null
abc 2 data
abc 3 data
abc 4 null
def 0 null
.
.
.
etc. A sort of report.
What would be a good way to generate the report in LINQ to SQL? My concept in SQL is to do:
select distinct Table1 cross join Table2 left join Table2
so I first get all combinations of state x level and then left join against Table2 again to get the data (and allow nulls for situations where Table2 doesn't have data for the specific state x level.
Not sure if there is a cooler way to do this in linq?
I found a sql to linq converter, but it didn't support cross joins ..
|
|
|
|
|
There is a LINQ forum just below here.
|
|
|
|
|
My web project is using interop to create word document. It works on my system since i have word installed on my system but Server does not have office installed so
How can i install Office.Interop.WOrd assembly on server.
Should i just copy the interop dll and register it or is there a setup i have to do?
|
|
|
|
|
Installing the interop assembly on the server won't help. If the server doesn't have Office installed, you can't use Office on the server.
Also, using Office interop from an ASP.NET application is not supported, and will most likely fail in interesting ways:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
You would do better to use a supported solution, such as the Open XML SDK[^], or DocX[^].
There's even an article introducing DocX here on CodeProject: C#: Create and Manipulate Word Documents Programmatically Using DocX[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
but both openxml and docx does not support conversion of word to pdf
|
|
|
|
|
So you have an X-Y-problem: you want to do X, think of a way you can solve, get stuck with that way, and now you ask us about that (wrong) way...
Ask the correct question!
|
|
|
|
|
yes i was asking the wrong way to do it.
I am using iTextSharp for converting HTML to PDF but itextsharp is not converting the CSS in the html.
do you have idea how to get around this and have an exact replica in PDF from html using itextsharp
|
|
|
|
|
As far as I am aware, you can;t do that - it is a breach of your licencing conditions, unless you purchase a copy of Office to install on the server.
And if your server is run by a web hosting company, they might want to be involved in that - and would probably not be happy if you just add copyrighted assemblies to their equipment!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
is the a free toolwhich support conversion of word to pdf
|
|
|
|
|
Can anybody help me to solve this issue?
This is my program to collect data from a xml structure to my data structure,
this is working fine but let me explain:
for example i have a xml file for collect data have 10 datas need collect and parse, if i let the xml source file 10 datas so the parser program show error: index was out of range must be nonnegative and less than the size of the collection
But if i remove data 6 to 10 (just keep from 1 to 5) the parser working fine!
Here's my code
var questConds = GetConditions(quest, "finished_quest_cond");
if (questConds.Count > 0)
{
if (q.start_conditions == null)
q.start_conditions = new QuestStartCondition();
q.start_conditions.finishedQuestSteps = new List<QuestStep>();
for (int i = 0; i < questConds.Count; i++)
{
q.start_conditions.finishedQuestSteps.Add(questConds[i].questSteps[0]);
}
}
and GetConditions reference
static List<QuestStartCondition> GetConditions(Quest quest, string name)
{
List<String> conds = new List<string>();
Utility<Quest>.Instance.Export(quest, name, conds);
List<QuestStartCondition> startConditions = new List<QuestStartCondition>();
if (conds.Count > 0)
{
foreach (string cond in conds)
{
var finalConds = new Dictionary<int, QuestStep>();
var condition = new QuestStartCondition();
condition.questSteps = new List<QuestStep>();
if (name == "equiped_item_name")
{
int itemId = Convert.ToInt32(Program.clientItems.GetItem(cond).id);
QuestStep qs = new QuestStep(0, 0, itemId);
if (finalConds.ContainsKey(itemId))
{
QuestStep qsOld = finalConds[itemId];
}
else
{
finalConds.Add(itemId, qs);
}
}
else
{
string[] parseString = cond.Split(new string[] { " ", "," }, StringSplitOptions.RemoveEmptyEntries);
foreach (string c in parseString)
{
string[] condData = c.Split('_');
string questIdStep = (condData.Length > 1 ? condData[1] : condData[0]).TrimStart('q', 'Q');
condData = questIdStep.Split(':');
int questId = Int32.Parse(condData[0]);
int rewardNo = 0;
if (condData.Length > 1) rewardNo = Int32.Parse(condData[1]);
QuestStep qs = new QuestStep(questId, rewardNo, 0);
if (finalConds.ContainsKey(questId))
{
QuestStep qsOld = finalConds[questId];
}
else
{
finalConds.Add(questId, qs);
}
}
}
condition.questSteps = finalConds.OrderBy(p => p.Key).Select(p => p.Value).ToList();
startConditions.Add(condition);
}
}
return startConditions;
}
modified 12-Jun-14 7:03am.
|
|
|
|
|
Check your questSteps . It's pretty much impossible for questConds[i] to exceed the array, given that you do this:
for (int i = 0; i < questConds.Count; i++) (It's possible, but it would taken some work and multi threading)
So the most likely is that at least one of your questConds has a lero length number of queststeps which you do not check for.
The debugger should tell you if you look at the variables on the line that throws the error.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
First of all! Thanks fro your help and answer...
but what do you mean about: "So the most likely is that at least one of your questConds has a lero length number of queststeps which you do not check for."?
and do you have skype? maybe you can help me via skype!!!
|
|
|
|
|
Sorry: typo.
For "lero" I meant to type "zero".
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Oh you're right!!!
in data source xml file got a line have null data
<pre lang="xml"><finished_quest_cond1> </finished_quest_cond1>
so im passed this step!!
|
|
|
|
|
There you go!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I'm developing an application with a PropertyGrid.
The instance of the class I'm setting as the SelectedObject for the PropertyGrid contain an enum. This works great as the PropertyGrid automatically generates a ComboBox for the enum, letting the user choose any of the enum's elements.
But I'm forced to store the elements in a file and not in an enum. So the file can be changed without needing to compile the entire application. Also each element may also have spaces which enums don't support.
I'm unable to find a find a solution for this. I'm also afraid that this is impossible to do...
I have basically a file with this content:
Energy kW
Energy 10*kW
Energy 100*kW
The class I want to display in the PropertyGrid might look like this:
class PhysicalUnit
{
int value;
string[] units;
public int Value
{
get { return value; }
set { this.value = value; }
}
public string[] Units
{
get { return units; }
set { units = value; }
}
}
In this example I have assumed that the string[] units contains all elements from the file. When assigning an instance of the class to a PropertyView I would like to select a unit. Of course this don't work because I don't have a container object to hold the selected unit. Also the PropertyView don't create a ComboBox of the string[]. It appears that each GridItem in the PropertyGrid don't create a similar selection for arrays as enums.
If I make an enum of the units...
enum Units
{
EnergykW,
Energy10kW,
Energy100kW
}
...and create an instance member of the enum in the class with a public property, the PropertyView would automatically create me a ComboBox to select the elements and store what element I selected.
Any solution?
|
|
|
|