|
Thanks for your replies.
I came up with a solution that worked well but I don't know if it's optimal:
I search through all the information stored in each customer in the list. If the information in the customer object matches the information the user typed in the textbox the result is stored in a new list. If the information in the search textbox is empty it's also seen as a match. See below:
public int[] SearchCustomers(Customer searchCustomer)
{
//Create list for search results.
searchResult = new List<Customer>();
//Loop through all information in the customer-objects.
searchResult = customers.FindAll(delegate(Customer C) { return SearchFirstName(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchLastName(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchCity(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchCountry(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchStreet(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchZip(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchCellPhone(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchHomePhone(C, searchCustomer); });
searchResult = searchResult.FindAll(delegate(Customer C) { return SearchEmail(C, searchCustomer); });
The final result is a list containing the matches of all search words.
|
|
|
|
|
Hi,
How can i compress and extract a folder programmatically?
Can i get any sample source code?
Thankyou,
YPKI
|
|
|
|
|
You can use J# for that, or you need a third party component.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Why are you recommending J#?
|
|
|
|
|
You can Use GZipStream and DeflateStream classes from namespace System.IO.Compression
*12Code
|
|
|
|
|
You can Use GZipStream and DeflateStream classes from namespace System.IO.Compression
Hope this can help.
*12Code
|
|
|
|
|
|
|
hello
This scripts runs okay on SQL*Plus and TOAD (using same account "dev") but not sure when I try to wire it down through "System.Data.OracleClient" I keep getting the following error:
<br />
ORA-06550: line 1, column 8:\nPLS-00103: Encountered the symbol \"\" when expecting one of the following:\n\n begin function package pragma procedure subtype type use\n ... System.Data.OracleClient.OracleException...<br />
Here's the code:
<br />
DECLARE<br />
count_item int;<br />
BEGIN<br />
SELECT count(1) into count_item FROM user_sequences WHERE sequence_name = 'AUDITLOGSEQUENCE';<br />
IF count_item > 0 THEN<br />
begin<br />
dbms_output.put_line('drop sequence AUDITLOGSEQUENCE');<br />
EXECUTE IMMEDIATE ('DROP SEQUENCE AUDITLOGSEQUENCE');<br />
end;<br />
ELSE<br />
dbms_output.put_line('no need to drop AUDITLOGSEQUENCE');<br />
END IF;<br />
<br />
EXECUTE IMMEDIATE 'CREATE SEQUENCE AUDITLOGSEQUENCE<br />
MINVALUE 1<br />
MAXVALUE 999999999999999999999999999<br />
START WITH 1<br />
INCREMENT BY 1<br />
CACHE 20';<br />
dbms_output.put_line('AUDITLOGSEQUENCE created');<br />
<br />
SELECT count(1) into count_item FROM user_tables WHERE table_name = 'LOG';<br />
IF count_item > 0 THEN<br />
begin<br />
dbms_output.put_line('drop table LOG');<br />
EXECUTE IMMEDIATE ('DROP TABLE LOG');<br />
end;<br />
ELSE<br />
dbms_output.put_line('no need to drop table LOG');<br />
END IF;<br />
<br />
EXECUTE IMMEDIATE '<br />
CREATE TABLE LOG (<br />
Id numeric(19,0) NOT NULL,<br />
CreateDate date default sysdate NOT NULL,<br />
Thread varchar (255) NOT NULL,<br />
LogLevel varchar (50) NOT NULL,<br />
Logger varchar (255) NOT NULL,<br />
Message varchar (4000) NOT NULL,<br />
InnerException varchar (2000) NULL,<br />
CONSTRAINT PK_LOG PRIMARY KEY (Id)<br />
)';<br />
<br />
COMMIT;<br />
<br />
dbms_output.put_line('table LOG created');<br />
<br />
dbms_output.put_line('setup complete');<br />
EXCEPTION<br />
WHEN OTHERS THEN<br />
dbms_output.put_line('*** setup exception detected! ***');<br />
dbms_output.put_line('error code: ' || sqlcode);<br />
dbms_output.put_line('stack trace: ' || dbms_utility.format_error_backtrace);<br />
RAISE_APPLICATION_ERROR(-20000, 'AuditTrail.oracle.tables.sql - install failed');<br />
END;<br />
As you can see, the script is anonymous block taking no argument
And I looked at the code, can't see anything wrong.
<br />
oCmd = oConn.CreateCommand();<br />
oCmd.CommandText = DBUtil.FixParameterNameForOracle(oContext.DefaultDBProvider, StringUtil.ReplaceSpecialTokens(SQL));<br />
oCmd.CommandType = System.Data.CommandType.Text;<br />
<br />
oDataSet = new DataSet(CmdFilePath);<br />
oTable = new DataTable(Name);<br />
oDataSet.Tables.Add(oTable);<br />
oAdapter = oFactory.CreateDataAdapter();<br />
<br />
oAdapter.SelectCommand = (DbCommand)oCmd;<br />
oAdapter.Fill(oDataSet, Name);<br />
oCmd is of type "System.Data.OracleClient.OracleCommand". And it takes no parameter or input argument. I googled a bit closest I found is this:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/579b5a98-ec74-4f6f-b5b4-6919d8bc3e7c/[^]
But my script contains no parameter.
Also, using "oCmd.ExecuteNonQuery()" instead of dataAdapter.Fill didn't help. I finally found one get around (NOT A DECENT SOLUTION!), that is to collapse the multiline script to single line!
<br />
DECLARE count_item int; BEGIN SELECT count(1) into count_item FROM user_sequences WHERE sequence_name = 'AUDITLOGSEQUENCE'; IF count_item > 0 THEN begin dbms_output.put_line('drop sequence AUDITLOGSEQUENCE'); EXECUTE IMMEDIATE ('DROP SEQUENCE AUDITLOGSEQUENCE'); end; ELSE dbms_output.put_line('no need to drop AUDITLOGSEQUENCE'); END IF; EXECUTE IMMEDIATE 'CREATE SEQUENCE AUDITLOGSEQUENCE MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 INCREMENT BY 1 CACHE 20'; dbms_output.put_line('AUDITLOGSEQUENCE created'); SELECT count(1) into count_item FROM user_tables WHERE table_name = 'LOG'; IF count_item > 0 THEN begin dbms_output.put_line('drop table LOG'); EXECUTE IMMEDIATE ('DROP TABLE LOG'); end; ELSE dbms_output.put_line('no need to drop table LOG'); END IF; EXECUTE IMMEDIATE 'CREATE TABLE LOG (Id numeric(19,0) NOT NULL, CreateDate date default sysdate NOT NULL, Thread varchar (255) NOT NULL, LogLevel varchar (50) NOT NULL, Logger varchar (255) NOT NULL, Message varchar (4000) NOT NULL, InnerException varchar (2000) NULL,CONSTRAINT PK_LOG PRIMARY KEY (Id))'; dbms_output.put_line('table LOG created'); dbms_output.put_line('setup complete'); END;<br />
What the hell!? I have a big script next and I'm really not impressed ... any suggestion besides this?
Thanks
dev
modified on Tuesday, April 7, 2009 6:45 AM
|
|
|
|
|
found it... I fixed strSQL from application, removing all instances of newline
strSQL = strSQL.Replace('\n', ' ');
I'm very impressed by the work on System.Data.OracleClient, some quality code!
dev
|
|
|
|
|
I tried to list drives available in a system in checkedlistbox.When i click on the C:\ i want to list its files in a listview.I tried with the following but it does not work.Can you give me an alternative.<pre>
int p=checkedListBox1.SelectedIndex;
if(p==1)
{
try
{
reader = new XmlTextReader("path.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text: //Display the text in each element.
// Console.WriteLine(reader.Value);
String s1;
s1 = reader.Value;
String ss;
ss = checkedListBox1.CheckedItems.ToString();
String sss = ss + s1;
object o3 = (object)sss;
DirectoryInfo dire = new DirectoryInfo(sss);
//DirectoryInfo[] dirs = dire.GetDirectories();
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
DirectoryInfo di = new DirectoryInfo(foldername);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(foldername, "*.exe*");
//FileInfo[] fi = dire.GetFiles();
foreach (String filename in files)
{
lvi = new ListViewItem();
lvi.Text = filename;
listView1.Items.Add(lvi);
}
this.Controls.Add(listView1);
}
}
}
break;
}
}
}
catch (System.Exception err)
{
MessageBox.Show("Error: " + err.Message);
}
}
|
|
|
|
|
Two things.
First you forgot to include the closing </pre> tag.
Secondly, what you are trying to do is sort-of like Windows Explorer so a quick google on 'explorer c#' reveals My Explorer In C#[^], as the first hit.
If that doesn't give you any ideas, google for yourself and have a look at some of the other hits.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all,
I'm reading files from a certain folder and save everything into the database. I have a problem of reading multiple lines for a certain heading in a file and save them into one variable (to be saved into the database later).
e.g File content looks like this:
1. Date of Transaction :
20030728
2. Type of funds :
_Cash
3. Amount of Transaction(s) in Rand Value:
13500.00
4. Currency :
ZAR
PART H: List of available documents
Deal slip
Moneygram form
Copy of ID
BOP form
Gift declaration
I'm reading each line and save the value into a variable to be saved in the databse. e.g:
while ((line = reader.ReadLine()) != null)
{
if (line != null && line.Contains("1. Date of transaction :"))
{
line = reader.ReadLine();
DateOfTransaction = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("2. Type of funds :"))
{
line = reader.ReadLine();
TypeOfFunds = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("3. Amount of Transaction(s) in Rand Value:"))
{
line = reader.ReadLine();
AmountOfTransaction = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("4. Currency :"))
{
line = reader.ReadLine();
Currency = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("PART H: List of available documents :"))
{
line = reader.ReadLine();
PartHListOfAvailableDocs = line;
line = reader.ReadLine();
}
}
Heading (PART H: List of available documents) from the file is having multiple lines underneath it. How do I read each line and save them all in variable 'PartHListOfAvailableDocs'.
I'd really appreciate your help in this regard.
Thanks.
|
|
|
|
|
Hi,
you could create a loop which reads a line, appends it to what you already have (with a separator), and test for done, which either is something you would recognize as end of list, or end of file/stream.
Yours is a strange file format!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi
I have a listview control in Form1 which displays the file information.I have another listview control in Form2.Whatever gets displayed in listview of Form1 should also be displayed in ;listview of Form2.I tried using the object of Form2 but it dint work.Can you give your suggestions?
In form1<pre>
for2=new Form2();
for.listView1.Items.Add();
|
|
|
|
|
mrithula8 wrote: or2=new Form2();
This shows that you know nothing about object oriented programming. I suggest you buy a book and read it.
And use delegates for your specific problem
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
hi Experts
Pls Tell Me When We Have To Use Abstract Class Or When Interface with Real Life Example
and Program in C#.NET.
I Know The difference But i Not Getting When We Have one of Them.
Dinesh Sharma
|
|
|
|
|
If you want your base type to provide some default functionality out of the box, go for an abstract class. If you want everything to be up to your derived types, go for an interface.
For instance, if I want a Parser type whose descendants will parse files from multiple clients but those file formats have nothing in common, I'd make Parser an interface.
Also bear in mind you can inherit a type from at most one class, abstract or not. Interfaces don't have such restrictions.
|
|
|
|
|
Sharma Dinesh Kumar wrote: When We Have To Use Abstract Class Or When Interface
sorry for my bad English
- use abstract when you want to design code that only in serial derivation objects
- use interface when you want to design code that can be implemented in parallel derivation objects
sample for using abstract object
public abstract class A(){...}
public abstract class B(){...}
class DA : A{...}
class DB : B{...}
you can compare to this sample of using interface
public interface IA{...}
public interface IB{...}
class A : IA{...}
class B : IB{...}
class AB : IA, IB {...}
there are plenty resources from net, try search in Google with keywords "OOP in C#"
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
An interface says what properties, methods etc a class must have if it's to implement it but leaves the implementation up to the end class.
An abstract class will provide a default implementation.
You can implement many interfaces in one class, but only one abstract class.
Imagine you wanted to create vehicle classes Car and Bike . One thing they have in common is they have wheels so could have a property WheelCount . Because the number of wheels differs between the two classes it makes no sense to define this in a base class as it'd be wrong for one of them. Better to have an interface that both implement.
public interface IVehicle
{
int WheelCount { get; }
} Let's assume all cars have 4 wheels and all Bikes 2. We could now create base classes where this is hard coded.
public abstract class CarBase
{
public int WheelCount
{
get { return 4; }
}
}
public abstract class BikeBase
{
public int WheelCount
{
get { return 2; }
}
} Cars have doors in varying numbers so lets create an interface for that.
public interface ICar : IVehicle
{
int DoorCount { get; }
} We can now create a Car class like that derives from CarBase and implements ICar and is also IVehicle .
public class Car : CarBase, ICar
{
private int _DoorCount;
public Car(int doorCount)
{
_DoorCount = doorCount;
}
public int DoorCount
{
get { return _DoorCount; }
}
} and for the bike (no further implementation so far)
public class Bike : BikeBase, IVehicle
{ } You can now instanciate these classes treating all Car s as ICar , all Bike s as IBikes , or all vehicles as IVehicle
Car myCar = new Car(4);
Bike myBike = new Bike();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi all,
I created a Licensed windows forms controls in Internet Explorer,i sell this control to let customer develop web application.
My question is: the licenses file and Dll file is stored under the same folder in server. if the end-user who visit these site. it can download .licenses file and dll file, then they can also create own web application and not purchasing dll. how to limit end-user to use this dll file.
please help me!
the follow url is how to licensed control:
http://windowsclient.net/articles//licensing.aspx
<LINK REL="licenses" HREF="licensedwincontrol.html.licenses">
<OBJECT id = ctrl HEIGHT="200" WIDTH="200"
classid="http:LicensedWinControl.dll#Licensing.LicensedWinControl" >
<PARAM ID="Text" VALUE="Hello from the licensed control">
<PARAM ID="Backcolor" VALUE="Red">
</OBJECT >
|
|
|
|
|
|
how to read data from excel and display it in a list box using visual c# ????
|
|
|
|
|
This is a multi step process. The data in an Excel sheet may or may not be suitable to show in a listbox. Which bit have you tried ? What research have you done ? Where are you stuck ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I am not understanding how to go about it actually !!!
E.g..if i fill 4-5 columns of data in an excel sheet, i want to display them in my form (without any grid view)....[just d values]. I wanted to try with list box, but i guess its not working out for me !!!
can u help me plz...!!
|
|
|
|