|
Just use the .Net ComboBox[^] in the same way.
It's time for a new signature.
|
|
|
|
|
I have a long string which I need to check its existence in database. The string is follows:
string str = AU000AC20095=YBAX ,XS0088980494=MLIL,IT0003953350=HVBT
To make it sql compliant like.
Following is the sql query I need to execute:
SELECT ISIN_Universe_Id,ISIN,RIC,DateCreated from ISIN_Universe where ric in
('AU000AC20095=YBAX','XS0088980494=MLIL','IT0003953350=HVBT')
So I declared a varchar variable and passing this string. In C# code, i am using the following function for this:
public string CreateRICList(RICObject[] ricobj)
{
StringBuilder sb = new StringBuilder();
sb.Append("'");
for (int i=0; i<=ricobj.Length - 1; i++)
{
sb.Append("''");
sb.Append(ricobj[i].RIC);
sb.Append("''");
sb.Append(",");
}
string lstrics = sb.ToString();
if (lstrics.EndsWith(","))
lstrics.Replace(",","'");
return lstrics;
}
However, the string is not forming correctly. Is there any issue with the above code? Or is there any other method which I can pass the whole string at a stretch? Please help.
This is my stored procedure:
EXEC ('SELECT ISIN_Universe_Id,ISIN,RIC,DateCreated from ISIN_Universe
WHERE RIC IN ( ' + ''+ @LISTOFRICS + ''+ ')
AND DATECREATED > ''' + @PREVDAY + ''' AND DATECREATED < '''+@NEXTDAY+'''')
Thanks
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
The issue fixed. The string manipulation function refactored as follows:
StringBuilder sb = new StringBuilder();
for (int i=0; i<=ricobj.Length - 1; i++)
{
sb.Append("'");
sb.Append(ricobj[i].RIC);
sb.Append("'");
sb.Append(",");
}
string lstrics = sb.ToString();
if (lstrics.EndsWith(","))
lstrics = lstrics.Remove(lstrics.LastIndexOf(","),1);
return lstrics;
Probably it will help somebody.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Hi...
I want to display analog clock.
I have a textbox . once I enter time in textbox and click button, the same time should be set on analog clock.
how would I proceed in windows application in C#.net.
I basically belong to webapplication community.
thanks,
By:
Hemant Thaker
|
|
|
|
|
|
Hi sir,
In VC++ we use str.Find();
How can we use the same in C#
Its working good in VC++
Here is the VC++ code i did:
CString strvalue;
CString strTemp;
for()
{
if(strTemp.Find(strvalue)==0)
m_ctrlCombo.AddString(strTemp);
}
I am trying the same in C#
But in C# we dnt have str.Find(),any other method to find it
Here is wat i am trying
ArrayList List = new ArrayList();
List.Add("AAA");
List.Add("AA");
List.Add("BB");
List.Add("BB");
for (int i = 0; i < List.Count; i++)
{
string value = List[i] as string;
if(value.Equals("AA"))
comboBox1.Items.Add(value);
}
but i am getting all the value from ArrayList.
Any idea
Thanks
Raj
|
|
|
|
|
You must try this out, if u really want to iterate :
ArrayList List = new ArrayList();
List.Add("AAA");
List.Add("AA");
List.Add("BB");
List.Add("BB");
foreach (string item in List)
{
if (item.Equals("AA"))
comboBox1.Items.Add(item);
}
else, u can always go with this :
ArrayList List = new ArrayList();
List.Add("AAA");
List.Add("AA");
List.Add("BB");
List.Add("BB");
if (List.Contains("AA")
comboBox1.Items.Add("AA");
Ram
|
|
|
|
|
If you you are using .net3.0 or higher you can use this:
List<string> list = new List<string>();
list.Add("AAA");
list.Add("AA");
list.Add("BB");
list.Add("BB");
foreach (string found in list.FindAll(x=> x=="AA"))
comboBox1.Items.Add(value);
The above code is one way if achieving what you want. The generic list (equivalent to a c++ template) has a few advantages, the list is strongly typed (in this case all elements are strings). Additionally the generic list has more methods allowing you to find stuff in the list over the old ArrayList . The only thing I'd say (and it's a drawback in the code snippet I've added) is that the predicate syntax looks a little weird if you aren't used to it: list.FindAll(x=> x=="AA")
See Generic List MSDN[^] for members of a generic lists if interested.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Not an answer to your question, but a suggestion.
An ArrayList is generally not recommended as every item has to be converted to/from a object . This boxing/unboxing is an unecessary performance hit and more importantly can make working with the items (and therefore the code) more complicated.
If the items are all of the same type then use List<T> (where T is the type of your object, so for the example you have given use List<string> . There are other collections in System.Collections.Generic and System.Collections.ObjectModel that you may find useful depending on what you are using the list for. I would recommend using the generic types where available or the ones that are type specific such as StringCollection .
If you have mixed classes that you want in a collection but they derive from a common base class or interface then you can have a collection of that eg: List<IMyBaseInterface> .
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi Experts,
I am trying to use
ArrayList List = new ArrayList();
I am getting an error msg as
The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)
Even i tried,including the namespce :
using System.Collections.Generic
using System.collection
Still i am getting error.
Any idea what i must include
Thanks
Raj
|
|
|
|
|
raju_shiva wrote: using System.collection
This just might be a typo, but you should be using System.Collections ;
If this is right, then what version of the framework are using - remember Silverlight does not have an arrayList .
|
|
|
|
|
Hi sir,
As i am new to C#.I am comfused a bit to convert a code from VC++ to C#
which i did,
This is what i did in VC++
std::map<CString,CString>m_mapId;
m_mapId["AA"];
m_mapId["AAA"];
m_mapId["BB"];
m_mapId["BBB"];
CTest1View::OnEditchangeCombo1()
{
CString strvalue;
CString strTemp;
m_ctrlCombo.GetWindowText(strvalue);
std::map<CString,CString>::iterator it=m_mapId.begin();
m_ctrlCombo.ResetContent();
for(; it!=m_mapId.end();it++)
{
strTemp = it->first;
if(strTemp.Find(strvalue)==0)
m_ctrlCombo.AddString(strTemp);
}
m_ctrlCombo.SetWindowText(strvalue);
m_ctrlCombo.ShowDropDown();
}
I am trying it in C#
List<string> cities = new List<string>();
cities.Add("AAA");
cities.Add("AA");
cities.Add("BBBB");
cities.Add("BB");
comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
foreach (string A in cities)
{
MessageBox.Show(AA);
}
}
I am not getting how to loop till the end of list and find the character in the strings(one by one throughout the list)
and displaying them
Can anyone help me
Thanks
Raj
|
|
|
|
|
You might want to take a look at the Find method in a generic list.
|
|
|
|
|
Hi...,
Am in need to get the list of all page labels(numbers)..
In pdf Files the page (Labels)numbers be mentioned as
1. Roman letters(I,II,III.....)
2. Alphabets(A,BC,D,....)
3. Integers(1,2,3,4......)
And so on....
My input is a pdf file..
I have to read the page(Labels) numbers ... in a list or messageBox..
Am using the itextSharp libraries com
any url, help docs great helpful to me.
Regards,
Eswar
|
|
|
|
|
In my application I register a catch all unhandled exception handler with the following code:
AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
Strangely enough though sometimes, when the application is minimized and then restored, it crashes and show the standard Microsoft error reporting window:
"Application has encountered a problem and needs to be closed"
Why could that be? What can be done? Any ideas?
Notably this application is launched by a very simple launcher in a different AppDomain which does almost nothing, except starting a new app domain with file shadow copy = true.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Since you have more than one AppDomain, you would also need more than one AppDomain.CurrentDomain.UnhandledException += someHandler; . And at most one of those could touch the GUI.
From all I've read one can come close to, but never achieve, a situation where all exceptions are caught. There are some very nasty ones when threads are being aborted.
This is what Daniel Grunwald posted on 07-AUG-2008:
The following event handlers seem to catch 97%* of the exceptions:
System.AppDomain.CurrentDomain.UnhandledException (catches all exceptions on secondary threads)
System.Windows.Forms.Application.ThreadException (catches exceptions on the Windows Forms thread)
System.Windows.Threading.Dispatcher.CurrentDispatcher.UnhandledException (catches exceptions in the WPF dispatcher)
try{}catch{} in void Main (catches exceptions on the Main thread that crash Windows Forms/WPF)
The missing 3% are fatal exceptions (e.g. stack overflow) and exceptions in Drag'n'Drop events (both in Windows.Forms and WPF) - those get silently swallowed if not caught in the event handler.
Note that I am able to handle AppDomain.UnhandledException fine without the compatibility setting. You still get the event in .NET 2.0, but the exception will cause the process to terminate after the event handler has run. But you can use the event to display a MessageBox/custom error dialog. You could even keep the app (sort of) going on by putting an infinite sleep at the end of the event handler.
|
|
|
|
|
Thanks Luc!
I will do some more test with the System.Windows.Threading.Dispatcher.CurrentDispatcher.UnhandledException, will see if it helps!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi all,
Could you please let me know which property of the chart object will allow me to format values in Currency?
I want to have my Y axis to show Currency Amonut Like ($100,$200,%300 etc...)
Here is my code..
How can i format the chart control so that the revenue apprears in £ sign?
At the moment its jUst showing Numbers not having a $ sign.
Here is Code:
With dt
.Columns.Add(New DataColumn("Hours", System.Type.GetType("System.String")))
.Columns.Add(New DataColumn("Revenue", System.Type.GetType("System.String")))
.PrimaryKey = New DataColumn() {dt.Columns("Hour")}
End With
Using con As SqlConnection = New SqlConnection(Session("ConnectionString").ToString)
Using com As SqlCommand = New SqlCommand(strCommand, con)
con.Open()
Dim i As Integer = 0
Using reader As SqlDataReader = com.ExecuteReader
While reader.Read()
' Dim sSeries As String = reader(0).ToString.Trim.
Dim sSeries As String = reader.GetName(i)
Dim dr As DataRow
Dim sData As String = ConvertToString(reader(0))
If sData = "Total" Then
Else
' For f As Integer = 1 To reader.
dr = dt.NewRow()
'dr("Hour") = reader.GetName(i)
Try
dr("Hours") = Convert.ToString(reader(0))
dr("Revenue") = Convert.ToDecimal(reader(1))
Catch ex As Exception
End Try
dt.Rows.Add(dr)
dt.AcceptChanges()
End If
End While
Dim Count As Integer = dt.Rows.Count
If Count = 0 Then
Exit Sub
End If
With Chart1
.Titles.Add("Revenue Generated by Hour and Channel ")
.Series.Clear()
.Series.Add("Revenue")
.ChartAreas.Clear()
.ChartAreas.Add("ChartArea1")
.ChartAreas("ChartArea1").AxisX.Title = "HOUR"
.ChartAreas("ChartArea1").AxisY.Title = "Revenue"
.Series("Revenue").ChartType = SeriesChartType.Column
.Series("Revenue").IsValueShownAsLabel = True
.DataSource = dt
.Series("Revenue").XValueMember = "Hours"
.Series("Revenue").AxisLabel = "Revenue"
.Series("Revenue").XAxisType = AxisType.Primary
.Series("Revenue").YValueMembers = "Revenue"
.DataBind()
.Legends.Add("Legend1")
.AlignDataPointsByAxisLabel()
End With
modified on Thursday, July 1, 2010 3:18 PM
|
|
|
|
|
I've checked. That's not C# - not even with some hinky dink extension methods going on there. Please take your VB.NET out of our nice case sensitive forum.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for your comment.
DataTable dt = new DataTable();
{
006 dt.Columns.Add(new DataColumn("Hours", System.Type.GetType("System.String")));
007 dt.Columns.Add(new DataColumn("TotalCall", System.Type.GetType("System.String")));
008 dt.Columns.Add(new DataColumn("Minutes", System.Type.GetType("System.String")));
009 dt.Columns.Add(new DataColumn("Revenue", System.Type.GetType("System.String")));
010
011 dt.PrimaryKey = new DataColumn[] { dt.Columns("Hour") };
012
013 }
014
015 using (SqlConnection con = new SqlConnection(Session("BMEAS_ConnectionString").ToString)) {
016 using (SqlCommand com = new SqlCommand(strCommand, con)) {
017 con.Open();
018 int i = 0;
019 using (SqlDataReader reader = com.ExecuteReader) {
020 while (reader.Read()) {
021 string sSeries = reader.GetName(i);
022 DataRow dr = null;
023 string sData = ConvertToString(reader(0));
024
025 if (sData == "Total") {
026
027 } else {
028 dr = dt.NewRow();
029 try {
030 dr["Hours"] = Convert.ToString(reader(0));
031 dr["TotalCall"] = Convert.ToString(reader(1));
032 dr["Minutes"] = Convert.ToString(reader(2));
033 dr["Revenue"] = Convert.ToDecimal(reader(3));
034 } catch (Exception ex) {
035 }
036
037 dt.Rows.Add(dr);
038
039 }
040
041 }
042 int Count = dt.Rows.Count;
043 if (Count == 0) {
044 return;
045 }
046
047 {
048 Chart1.Series("Default").Color = Color.MediumSeaGreen;
049 Chart1.Series("Default").BackSecondaryColor = Color.Green;
050 Chart1.Series("Default").BackGradientStyle = GradientStyle.DiagonalLeft;
051
052 Chart1.Series("Default").BorderColor = Color.Black;
053 Chart1.Series("Default").BorderWidth = 2;
054 Chart1.Series("Default").BorderDashStyle = ChartDashStyle.Solid;
055
056 Chart1.Series("Default").ShadowOffset = 2;
057
058 Chart1.Titles.Add("Revenue Generated by Hour and Channel ");
059 Chart1.Series.Clear();
060 Chart1.Series.Add("Revenue");
061 Chart1.ChartAreas.Clear();
062 Chart1.ChartAreas.Add("ChartArea1");
063 Chart1.ChartAreas("ChartArea1").AxisX.Title = "HOUR";
064 Chart1.ChartAreas("ChartArea1").AxisY.Title = "Revenue";
065
066 Chart1.Series("Revenue").ChartType = SeriesChartType.Column;
067 Chart1.Series("Revenue").IsValueShownAsLabel = true;
068
069 Chart1.DataSource = dt;
070 Chart1.Series("Revenue").XValueMember = "Hours";
071 //.Series("").AxisLabel = "Hours"
072 Chart1.Series("Revenue").AxisLabel = "Revenue";
073 Chart1.Series("Revenue").XAxisType = AxisType.Primary;
074 Chart1.Series("Revenue").YValueMembers = "Revenue";
075
076 Chart1.DataBind();
077 Chart1.Legends.Add("Legend1");
078 Chart1.AlignDataPointsByAxisLabel();
079 }
080 // .Legends.Add("Legend1")
081
082 {
083 Chart2.Titles.Add("Total Calls and Minutes Generated By Hour");
084 //.Titles.Add(
085 Chart2.Series.Clear();
086 Chart2.Series.Add("TotalCall");
087 Chart2.Series.Add("Minutes");
088 // .Series.Add("Revenue")
089 Chart2.ChartAreas.Clear();
090 Chart2.ChartAreas.Add("ChartArea1");
091 Chart2.ChartAreas("ChartArea1").AxisX.Title = "HOUR";
092 Chart2.ChartAreas("ChartArea1").AxisY.Title = "Minutes";
093
094
095 Chart2.Series("Minutes").ChartType = SeriesChartType.Column;
096
097 //.Series("Minutes")("DrawingStyle") = "Emboss"
098 Chart2.Series("Minutes").IsValueShownAsLabel = true;
099
100 Chart2.Series("TotalCall").ChartType = SeriesChartType.Column;
101
102 Chart2.DataSource = dt;
103
104 Chart2.Series("TotalCall").XValueMember = "Hours";
105 Chart2.Series("TotalCall").YValueMembers = "Totalcall";
106 Chart2.Series("Minutes").XValueMember = "Hours";
107 Chart2.Series("Minutes").YValueMembers = "Minutes";
108 Chart2.DataBind();
109 Chart2.Legends.Add("Legend1");
110 Chart2.AlignDataPointsByAxisLabel();
111 }
112 // .Legends.Add("Legend1")
113
114 }
115 }
116 con.Close();
117 }
|
|
|
|
|
That's still isn't valid C#. The converter you used sucks.
Why don't you try the VB forum?
|
|
|
|
|
Signature updated!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Like it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi everyone,
I have done single client-server application using c#. Now i have to made that application for multiple clients. kindly guide me.
Regards
|
|
|
|
|
Is they always seem to call at the same time demanding an on site visit Friday at 4:30pm.
If you have implemented a "single" client-server application the multiple client application should work with no changes. There is no difference. Ahem, there should be no difference. When a TCP connection is established from the Listening port he OS assigns it a temporary high number port so the listener can continue to listen. No work should need to be done. The only other issue is if your command processing does not support the ability to distinguish different requests from different clients but again that is such a large area.
|
|
|
|