|
It's possible that GetDBTable is entered while another thread is reading the table.
You have to put the "lock(DS) {" statement in front of the "if (...Contains)" line.
|
|
|
|
|
Hi,
Thanks it would solve my problem. However, it will always lock the DS object even during readings and what I wanted is to lock the object only during writing. After some search, I came up with a solution, you may take a look at it. I would appreciate your opinion.
if (DS.Tables.Contains(TableName) == true)
{
return DS.Tables[TableName];
}
//Load the table's data
if (Monitor.TryEnter(DS))
{
try
{
using (SqlConnection conn = new SqlConnection(ConnectStr))
{
SqlDataAdapter DA = new SqlDataAdapter(SelectStr, conn);
DA.Fill(DS, TableName );
DA.Dispose();
}
CommonUtils.WriteToSystemLog("Filled table", EventLogEntryType.Information);
}
finally
{
Monitor.Exit(DS);
}
}
else
{
//Another thread is filling the DataSet ->wait
while (DS.Tables.Contains(TableName) == false)
{
}
CommonUtils.WriteToSystemLog("Waited on the table for filling", EventLogEntryType.Information);
}
return DS.Tables[TableName];
BR Sangra
|
|
|
|
|
I don't know if the Tables-Collection is thread-safe, but you can do a double-check also like this:
public override DataTable GetDBTable(string TableName, string SelectStr)
{
if (DS.Tables.Contains(TableName))
return DS.Tables[TableName];
lock(DS) {
if (DS.Tables.Contains(TableName))
return DS.Tables[TableName];
using (SqlConnection conn = new SqlConnection(ConnectStr)) {
....
}}}
|
|
|
|
|
Yes your solution is clearer and it worked. Really appreciate your help!
BR Sangra
|
|
|
|
|
Hi
I have an app, which main form at startup isn't shown. It is minimized, it is not shown in the taskbar and the app present itself via a systray icon. If u whant to see the Form, you click on the systray icon and I maximize the Form.
The problem is, that I get a small form bar in the lower left corner of the screen, when my app is minimized and I don't whant that, since I got my systray icon to remaximize it with.
How do I remove that annoying bar?
I tried setting the Opacity property and that actually worked. Great!
Here I need to point out, that the app is a Support app, which our support division can use when using Remote Desktop on our customers PCs.
I therefore tried using Remote Desktop and to my surprise the app whent invisible! I could not maximize it anymore. After some debugging I discovered that the Opacity property caused that!?!
So if any of you have a solution other than using the Opacity property I would greatly appreciate it.
TIA
-spif2001
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
Have you tried -
form.Size = new Size(0,0);
?
|
|
|
|
|
the bar still shows af resizing
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
Try setting the FormBorderStyle property of the form to FormBorderStyle.None.
|
|
|
|
|
hmmm - that works when my app starts, but when I Maximize it and the Minimize it again, the Form bar reappears...
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
It just came to my mind that you could instead of minimizing the form and trying to hide the bar just make the whole form invisible (form.Visible = false;).
|
|
|
|
|
I tried that too to no avail.
And I got it working using Hide(), except at startup. I tried to Hide() it in another thread like this:
public MainForm()
{
InitializeComponent();
Thread t = new Thread(new ThreadStart(HideFunc));
t.Start();
}//constructor
private void HideFunc()
{
Thread.Sleep(1);
this.Hide();
}
It works (even though the Form flickers before hiding). If I remove the Sleep(1) call the Form whont hide!?
Am I missing some fundamental programming issue here or what?
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
Hi all,
I am fairly new to C# and I was wondering if any of you can help me with Crystal...
I have a dialog box with a couple of controlls on it! I want to select a sales person, a starting date and an end date, send Crystal a little sql stmt based on the values I selected from the dialog, and draw my report!
Any help will be greatly appreciated!
Kind greetings
Willem
|
|
|
|
|
I have to say I officially hate Crystal, sorry. But I have to use it. I'll try to tell you what I have done, and hopefully this will get you started in the right direction.
First I created an XSD by clicking on the project in question --> Add New Item --> XML Schema. Open the schema in the designer and put in the fields and their data types for the data as you want to see it on the report. You can add elements and such by right-clicking in the schema window.
After you are done with that, right-click in the schema window and select Generate Dataset. If you were to click your "Show All Files" button on your project, you would notice that you now have a new .cs file underneath your xsd schema. This is known as a "strongly-typed dataset", if I'm not mistaken.
Now, Crystal is ready to accept your information. The next step is designing the Crystal report itself. Add New Item --> Crystal Report, and you get a report file .rpt. If you right-click in the Field Explorer (on the left hand side) [and probably this is available somewhere in the menu system], you need to find Add/Remove Database. You should see a list of potential data sources, and you should see your strongly-typed dataset here.
I won't walk you through designing a report [edit]although happy to give help if requested[/edit]...
Next step is displaying the report. Create a new blank Windows Form in your project, and drag a CrystalReportViewer component on to the form, and dock it using Fill. [BTW, You probably need to be referencing "CrystalDecisions.CrystalReports.Engine", "CrystalDecisions.ReportSource", "CrystalDecisions.Shared", and "CrystalDecisions.Windows.Forms" in your project]. If you don't see a CrystalReportViewer component anywhere in your toolbox, right-click your toolbox, choose add/remove items, and scroll to CrystalReportViewer.
Finally, to actually pass the information and show the form, you need some or all of the following code:
dsMyTypedDataSet reportSource = new dsMyTypedDataSet ();
reportSource.ReadXml(myFileName);
.
rptMyReportClass rpt = new rptMyReportClass();
rpt.SetDataSource(reportSource);
.
rpt.SetParameterValue("MyParam", myValue);
.
frmReportViewer mdiReportViewer = new frmReportViewer();
.
crystalReportViewer1.ReportSource = rpt; .
.....
.
mdiReportViewer.Show();
.
crystalReportViewer1.ShowLastPage();
NumPages = crystalReportViewer1.GetCurrentPageNumber();
crystalReportViewer1.ShowFirstPage();
this.Text += String.Format(" : {0} Page{1}", NumPages, NumPages == 1 ? "" : "s");
This last bit was what I do to retrieve the number of pages and display it, else it doesn't know how many pages you have.
This is not perfect I'm sure, but please try it out and let me know what doesn't work so I can help you fill in the details.
-- modified at 11:18 Monday 3rd October, 2005
|
|
|
|
|
Hi Susan!
Don’t worry darling! You are not the only one that hates this tedious, incomprehensible, infernal reporting tool! But, alas, here we are using it! I much prefer using SQL reporting, but not all of our clients can afford something that spectacular!
Thank you for replying to my post! I am sure to give your suggestion a try and I promise to keep you posted! I am currently using VCpp 6.0 for development at work, and the only time I have playing around with C# is in my private time! So… it might take me a little while to get back to you!
(On the side lines, are you from SA by any chance? Because I had this rather pleasant
instructor a while back (2002…2003? I think…) and I thought of trying to contact her and perhaps have a little something to drink!)
Thanks again
Willem Le Roux
|
|
|
|
|
Willem Le Roux wrote:
the only time I have playing around with C# is in my private time! So… it might take me a little while to get back to you!
Take your time, I hope the code sample, although a little rambling, will be of help. I saw that it was formatted really strangely, so I edited it, just for formatting.
Willem Le Roux wrote:
On the side lines, are you from SA by any chance
No, but thanks for asking! I'll have a drink with you anyway! Oh, wait...I don't drink...drat.
See my profile[^] to see where I work
===================
My very first article: Visual Source Safe 6.0 Recursive Rollback[^]
10/3/2005
|
|
|
|
|
Thanks for your help Susan!
I read your "edited" version and I will be playing around with Crystal tonight and again on Thursday! Like I said, I will keep you posted on how I do!
I will pop you some mail when I am in the states again... which might only be in 4-5years or so! I have a friend that stays in California somewhere! Then I will pay my dues in the form of a cup of hot chocolate and a muffin! (Or something along those lines)
Thanks again Susan!
|
|
|
|
|
Hi all,
Can anybody tell me how to get my motherboards serial number?
Any help would be great!
Willem Le Roux
|
|
|
|
|
You can use WMI and the System.Managemnet namespace to get the serial number, IF AND ONLY IF your motherboard manufacturer supplies the WMI Management components to expose this information. Most don't. Check with your motherboard manufacturer for some kind of Management application that might install the required WMI classes.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave!
Thanks for your reply and I will surly give this a shot, but I am looking for something a little more... pertinent shall I say...
I want to get the registration key of motherboards of various types, ages, makes ECT. ECT. ECT. It is going to be WAY too much effort trying to explain this "Installation of WMI Management components" scenario to every user!
Perhaps there is an easier way to go about this scenario? Perhaps a MAC address or something to this avail. If you can be of ANY assistance, please let me know!
Kind greetings
Willem
|
|
|
|
|
Willem Le Roux wrote:
I want to get the registration key of motherboards of various types, ages, makes
WMI is the only way you're going to do this. And, still, that's IF the motherboard manufacturer supplies it.
There's no standard method to get this and no "registration key" for motherboards. There's various components that make up a motherboard that are scattered throughout the device manager though. That's accessible through the Setup API functions. There's no .NET class that wraps it. How useful that information is depends on what you mean by "registration key" and what you want to do with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey sorry Dave!
Little typo! My brain was clearly broken that day! Work overload! I mean the "serial number" of the motherboard. Or the serial number for any component that is standard on any motherboard for that matter! Or a MAC address... Anything on the motherboard that is standard and unique! I will have a look through the device manager and toy around a bit!
Once again, sorry for my little typo! "Registration key" of the motherboard! That is stupid!
Thanks for your effort Dave! Really appreciate it! Will keep you posted!
Cheers!
Willem
|
|
|
|
|
Again, there is no standard that says a manufacturer has to supply this information on a motherboard, or any component on it. The only "standard" access method is WMI. There is no API call you can make to get this information other than WMI.
On top of that, it appears that only system manufacturers, like Dell and HP, even supply this information at all. The serial number belongs to the entire system, not the motherboard.
Basically, what you want cannot be found on every notherboard. If you're looking for something to build a registration key with, this ain't it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want to know that how can i make toolbar in c#.net.and how to add that toolbar in IE.
Amit Grover
CDAC R&D
Gist Group
pune
|
|
|
|
|
|
//Below is my code, I want to show employee detail on the bases of employee id.
//I use pubs database of SQL Server [Winform C#.Net]
=========================================================
<b>//Crystal Report Object
CrystalReport1 cp = new CrystalReport1();
//
private void Form2_Load(object sender, System.EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("server=SK- WAQAS;uid=****;pwd=***;database=pubs");
SqlDataAdapter dsemp = new SqlDataAdapter("Select * From employee where emp_id=" + textBox1.Text.Trim(), con);
DataSet ds = new DataSet();
dsemp.Fill(ds,"employee");
cp.SetDataSource(ds);
//cp.SetParameterValue("emp_id",”AMD15433FDBT39435M”);
con.Close();
}
catch(Exception ce)
{
MessageBox.Show(ce.Message);
}
}</b>
=====================================================
Please tell where i do wrong.
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|