|
Uray Frank wrote: while (true)
{ string local_Test = System.DateTime.Now.ToString(); }
if that is harmless, all it tells me is your system has more than one core, and the remainder of the thread is involved in the problem somehow.
Uray Frank wrote: I think now my problem has something to do with the
Datatable or with the SqlConnection
and that is why you should have explained, or better yet shown, what these are doing in your app; your mock up does not show enough to explain the behavior IMO.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I have done some more investigation ... )
It has definitely something to do with the datatable.
The blocking occurs only when calling
local_SqlDataAdapter.Fill(local_DataTable);
or local_DataTable.Load(local_SqlDataReader);
When I just do
local_SqlDataReader = local_SqlCommand.ExecuteReader();
while (local_SqlDataReader.Read())
{ }
local_SqlDataReader.Close();
nothing is blocking
Well, I now know where exactly the problem is,
but what can I do now ?? )
Regards
Frank Uray
|
|
|
|
|
I don't know how big your table is; has it 2 columns, or 2000? does it contain texts, images, blobs? you may be overflowing physical RAM. Why do you want all data in memory in the first place? If it is going to be multi-user, you may end up with stale data somehow. It might be much better to perform the queries you need on the database itself. And if your user needs to select something, make it a two-stage approach, just like these forums do (you get one page at a time, and can navigate using PREV and NEXT etc).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hi All,
I want LINQ query to retrieve records from eventlog viewer with like operator.
Is there any LIKE operator in LINQ?
please help me.
Regards,
Sunil G.
modified on Wednesday, February 3, 2010 7:25 AM
|
|
|
|
|
|
Bear in mind that the event log entries are just a collection, you can retrieve items from it using something like the following:
var item = from EventLogEntry p in EventLog.GetEventLogs().First().Entries
where p.Message.Contains("Online")
select new { Id = p.InstanceId, Message = p.Message }; In this sample, I'm just picking from the first event log - you would probably want to refine this to find the log you are interested in explicitly. The Contains method is the closest you'll get to the Like operator.
"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
|
|
|
|
|
You can use the below code if you using LINQ to Objects
private void button1_Click(object sender, EventArgs e)
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer { CustomerID = "A12I", CustomerName = "Palash" });
customers.Add(new Customer { CustomerID = "B20G", CustomerName = "Ankesh" });
customers.Add(new Customer { CustomerID = "A100I", CustomerName = "Subhadip" });
customers.Add(new Customer { CustomerID = "C12G", CustomerName = "Namita" });
var result = (from c in customers
where c.CustomerID.StartsWith("A") && c.CustomerID.EndsWith("I")
select c).ToList();
foreach (Customer c in result)
{
MessageBox.Show(c.CustomerName);
}
}
}
public class Customer
{
public string CustomerID;
public string CustomerName;
}
for Search A%I . In case Of Search %I% you can use String Contains method to do that
In Case of LINQ to SQL You can Use the Syntax like
var result = (from c in db.Customers
where System.Data.Linq.SqlClient.SqlMethods.Like(c.CustomerID, "A%I")
select c).ToList();
|
|
|
|
|
hi,
i have multicolumn listview with two columns..nw i m setting values of second column like this
listview.items[i].subitems[1].text=somevalue;
but its not working for me.plz tell me where i m wrong?
|
|
|
|
|
with dataGriedVeiw you can do lot
|
|
|
|
|
When you say "it's not working" what do you mean?
Do you get an exception?
Does nothing display?
Does listview.items[i].subitems[1] exist?
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
If you have used the syntax properly,
I mean like this
listView1.Items[0].SubItems[1].Text = "SomeVal";
it should be working. If not please post your syntax and the error you are facing.
Jack Sparrow
|
|
|
|
|
Hi all,
I would greatly appreciate any assistance on this, I have no idea what is wrong
I have a program that runs through excel sheets and populates the following classes:
Product > (contains) > Recipe > (contains multiple) > Material
The population of the objects work 100%, but I keep getting a "No Persister for Product"
error when trying to .SaveOrUpdate(product);
Please go through the code examples and database structure below and let me know what I'm doing wrong. I've been battling for ages and simply can't find the right path. To confirm, I have included the mapping files as an embeded resource (this solved my previous problem).
Much appreciated and thank you in advance!
===================
Database structure:
===================
-Products Table-
Contains various fields, one of which is 'RecipeID' which links to the -Recipes Table-.
One product can have one recipe
-Recipes Table-
Contains ID, PercentageInKg, and MaterialID which links to the -RawMaterials Table-.
The RecipeID is not unique, if a recipe has 5 materials it will have
eg. ID=223 for all 5 entries (as the 5 entries form part of 1 recipe),
MeterialID to each unique material entry, and PercentageInKg for each MaterialID
which is the amount for this specific recipe
-RawMaterials Table-
Contains ID, Name, and CostPerKg.
The MaterialID is unique, listing specific raw materials and its cost per kg.
=================
Class Structures:
=================
public class Product
{
public virtual int ProductID { get; set; }
public virtual string Name { get; set; }
public virtual decimal BatchSize { get; set; }
public virtual decimal FormulaSG { get; set; }
public virtual string Appearance { get; set; }
public virtual string Smell { get; set; }
public virtual decimal Yield { get; set; }
public virtual string SolidsPercentage { get; set; }
public virtual string pH { get; set; }
public virtual string Viscosity { get; set; }
public virtual string Colour { get; set; }
public virtual string FoamDefinition { get; set; }
public virtual DateTime CreatedDate { get; set; }
public virtual Recipe Recipe { get; set; }
#region Overrides
public override bool Equals(object obj)
{...}
public override int GetHashCode()
{...}
#endregion
}
public class Recipe
{
public virtual int RecipeID { get; set; }
public virtual List<RecipeEntry> RecipeEntries { get; set; }
#region Overrides
public override bool Equals(object obj)
{...}
public override int GetHashCode()
{...}
#endregion
}
public class RecipeEntry
{
public decimal PercentageInKg { get; set; }
public Material RawMaterial { get; set; }
}
public class Material
{
public virtual int MaterialID { get; set; }
public virtual string Name { get; set; }
public virtual decimal CostPerKg { get; set; }
#region Overrides
public override bool Equals(object obj)
{...}
public override int GetHashCode()
{...}
#endregion
}
========
Mapping:
========
public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Table("Products");
Id(p => p.ProductID);
Map(p => p.Name);
Map(p => p.BatchSize);
Map(p => p.FormulaSG);
Map(p => p.Appearance);
Map(p => p.Smell);
Map(p => p.Yield);
Map(p => p.SolidsPercentage);
Map(p => p.pH);
Map(p => p.Viscosity);
Map(p => p.Colour);
Map(p => p.FoamDefinition);
Map(p => p.CreatedDate);
References(p => p.Recipe.RecipeID , "RecipeID");
}
}
public class RecipeMap : ClassMap<Recipe>
{
public RecipeMap()
{
Table("Recipes");
Id(p => p.RecipeID);
Component<RecipeEntry>(x => x.RecipeEntries, m =>
{
m.Map(x => x.PercentageInKg);
m.References(x => x.RawMaterial, "MaterialID");
});
}
}
public class MaterialMap : ClassMap<Material>
{
public MaterialMap()
{
Table("RawMaterials");
Id(p => p.MaterialID);
Map(p => p.Name);
Map(p => p.CostPerKg);
}
}
I can populate the objects which shows the correct amount of products, drills down to the recipe and materials for the recipe correctly, but cannot save anything.
I need a way to
1) Save the Product which will in turn save the recipe entries
(and materials, though i can get by doing this seperately)
2) be able to save the materials seperate
Hope you can help! Thanks again,
-Y-
|
|
|
|
|
Anybody?
I feel the silence of the universe oppressing my code! oh nooooo!
|
|
|
|
|
The application i am working requires to export the datagridview to excel file. With help of some articles here i am able to do the needful.
But i am interested in getting more details about these.
will you plz suggest me a good book from where i can start and gather more knowledge about all this.
such as-
working with MS office files,
with pdf.
with xml files
regards
|
|
|
|
|
hi all, i use the following algorithms to encrypt then to decrypt a sequence of bytes, but the decryption algorithm always return an exception
<Length of the data to decrypt is invalid<
i don't know why that, both algorithms are below..,
public class CryptorEngine
{
static public byte[] keyArray;
static public byte[] resultArray;
public static void Encrypt(byte[] toEncryptArray, bool useHashing)
{
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
CryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
CryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateEncryptor();
CryptorEngine.resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
}
}
public class DecryptorEngine
{
static public byte[] keyArray;
static public byte[] resultArray;
public static void Decrypt(byte[] toEncryptArray, bool useHashing)
{
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
DecryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
DecryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateDecryptor();
DecryptorEngine.resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
}
}
regards..........;
|
|
|
|
|
Hi All,
Can you please help me for following situation
I Am creating C# application which allow multiple user to work on same XML file which is on server
can any one have solution
The Stifler
--
Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
|
|
|
|
|
Why would you do that?
It's PAINFULL. There are many small/lite DBs around that would be more apropriate for this
like SQLLite, even the compact edition of SQL, or use a *.mdb/access.
All these are lot less painfull than using an XML with multi user.
|
|
|
|
|
you can solve this problem with set promotions to the users or set priorities to operations
|
|
|
|
|
Hi,
I have a small problem with Combobox Data binding.
I am binding data to combobox from database by using the following code.
SqlDataAdapter da1 = new SqlDataAdapter("select * from sampledb", con);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
cmbUnit.DataSource = ds1.Tables[0];
cmbUnit.DisplayMember = "UnitName";
After that I want to Insert New item to combobox by using the following code.
cmbUnit.Items.Insert(0, "Select");
But it is showing an error that "Item Collection can't be modified when the datasource property is set".
Can anyone please suggest me how to resolve that problem by using C# Combobox only.
Thanks&Regards
Pavani
|
|
|
|
|
Your combo is DataBound so it won't let you use the Items.Add() and others...
Couple of solutions:
1) Add it(the item) to the dataset(binding source) and refresh the combo.
2) Create a List of strings or whatever your combo dataset contains and than use:
comboBox1.DataSource = myList;
When you add an item to the list:
comboBox1.DataSource = null;
myList.Add("blah");
comboBox1.DataSource = myList;
|
|
|
|
|
Now I am watching the book, dragon book.
I want to know how to write a C# compiler, just only a simple compiler which can complie C# Hello world prgram.
Who can tell me how to do it?
|
|
|
|
|
See here[^].
It seems to be a good starting point.
|
|
|
|
|
thanks, I will see this aticle.
I try to write a hello world program using C#.
But I find that if not using the .net framwork, this C# program cannot run.
Perhaps, I will try to write a c or c++ compiler and then write this C# compiler.
|
|
|
|
|
How simple? What are you going to leave out? (unsafe code? arrays? return values? method arguments? nonstatic methods? local variables?)
It's actually not all that hard (compared to native languages), it's just a stack architecture so you don't need to worry about register allocation and the peculiarities of x86, and since the JIT compiler does a lot of optimizations anyway you can just skip all that (no SSA stage needed to get a reasonable output)
Hello World is just this (debug output, as MSIL in text):
.class private auto ansi beforefieldinit Program
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
.maxstack 8
L_0000: ldarg.0
L_0001: call instance void [mscorlib]System.Object::.ctor()
L_0006: ret
}
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 8
L_0000: nop
L_0001: ldstr "Hello World!"
L_0006: call void [mscorlib]System.Console::WriteLine(string)
L_000b: nop
L_000c: ret
}
}
You could skip the nops.
|
|
|
|
|
Thanks for your reply.
I do not understand the .net framework architecture.
I know that the last code program is writed with Microsoft middle language. (Just as assmebly).
But I do not know how to compile the C# code to the MSIL and compile the MSIL to the exe file, in my compiler.
|
|
|
|