|
Create a stored proc something like this and call it from your app.
IF( EXISTS( SELECT * FROM table WHERE PhoneNumber = @PhoneNumber) )
RETURN 1
ELSE
RETURN 0
only two letters away from being an asset
|
|
|
|
|
write a query and check it
|
|
|
|
|
I populated an OleDb DataTable using a multi-table SELECT statement and need to bind some textboxes and comboboxes with the values from either one or the other table contained in the SELECT statement.
However, when I run the program I get the following error:
Child list for SerialNumber cannot be created
What does that error mean?
Thanks.
|
|
|
|
|
polishprogrammer,
Maybe show the SQL you're trying to do and a bit of code...
Regards,
Gareth.
|
|
|
|
|
Thanks. Here's a piece of the SQL SELECT statement:
SELECT ServiceDetails.SerialNumber, ServiceDetails.ManuDate, ServiceDetails.Manufacturer, " +
"ServiceDetails.Customer, ServicDetails.GasType, " +
"SerialNumber.SerialNumber, SerialNumber.Manufacturer, SerialNumber.ManufacturerDate, " +
"SerialNumber.Owner, SerialNumber.GasType, " +
"FROM SerialNumber, ServiceDetails WHERE " +
"SerialNumber.SerialNumber=ServiceDetails.SerialNumber " +
"AND SerialNumber.Manufacturer=ServiceDetails.Manufacturer " +
"AND SerialNumber.ManufacturerDate=ServiceDetails.ManuDate " +
"ORDER BY SerialNumber.SerialNumber"
The databinding that causes the problem involves binding to, say, the Manufacturer field in the SerialNumber table due to the fact that the same field name exists in both tables. I need to qualify the name of the field, but am unsuccessful when trying it in a databinding context, such as:
this.cbManuSer.DataBindings.Add("SelectedValue", dtSer, "SerialNumber.Manufacturer");
If I bind controls to fields in the datatable filled by the SQL SELECT statement given above that have unique names (not belonging to both tables), the binding works fine, but qualifying the name by table doesn't work. I get the Child list for x not created.
There must be a piece I'm missing, but I could not find a discussion of this topic.
|
|
|
|
|
polishprogrammer,
I am not to sure about the error, but i noticed you have an extra comma where there doesn't need to be one.
polishprogrammer wrote:
"SerialNumber.Owner, SerialNumber.GasType, " +
"FROM SerialNumber, ServiceDetails WHERE " +
I am a bit puzzled by your db tables setup though. Why have 3 columns in 2 different tables that are storing the same values?
Regards,
Gareth.
|
|
|
|
|
Thanks. I wound up just changing the names of the fields in one of the data tables and that worked for the data binding issue. Regarding the repetitive fields, well, it takes the 3 fields to uniquely identify a record, but I want to separate the data into two tables because the information in these particular tables aside from the primary key fields is quite different and used in different contexts, for different purposes.
I suppose I could create a lookup table that would link an ID to the three fields and both tables could reference the look up table, but, well, that would require more software revision because the ServiceDetails table is a recent addition to the database in question whereas the SerialNumber table has been used extensively with its current structure for quite some time and I'd have to redo a bit of code to use a modified structure.
|
|
|
|
|
Hi i developed a tool , which allows you to download whole the source code from microsoft at once.
You don't need vs2008 for this, and you can debug the source code without vs2008.
Just grab your copy from Net Mass Downloader.
You can contact me about the tool via my mail address keremskusmezer@gmail.com
Best Regards
Kerem Kusmezer
|
|
|
|
|
There was an excellent article that someone wrote on relation to updating GUI from a seperate thread.
This article related to setting a property called RaiseExceptionOfSomeKind = false.
Very simple yet very effecient.
I am sad to report that I am blanking out compeltely on that article. If someone has the foggiest idea as to what am I talking about please post a link.
This is what happens when you give up drinking..amnesia.
Thanks
|
|
|
|
|
Updating a Gui from a thread other than the one it was created on "often leads to unpredictable results" (MSDN[^]). See here[^] for the proper way to do so.
|
|
|
|
|
Found what I was looking for. It took a little while to do the right search.
http://www.codeproject.com/KB/user-controls/AlternateMultithreadedGUI.aspx.
The property I was looking for is CheckForIllegalThreadCalls = false.
Back to drinking,
|
|
|
|
|
THRERE are two ways
1. the wrong way that microsoft allowed
Set this property like:
<br />
CheckForIllegalCrossThreadCalls = false;<br />
2. the right way :
create a delegate to the function that updates the GUI and a handler
and use the invoke Method to wake the method
see here : http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx[^]
Have Fun
Never forget it
|
|
|
|
|
Thank half-life. I was aware of the second way as well. I was experimenting with a few things so I thoiught of this CheckForIllegalCrossThreadCalls = false;
thing I read on codeproject a while ago.
|
|
|
|
|
glad to help
Have Fun
Never forget it
|
|
|
|
|
I wanted to add a dockable interface to my application and I don't really like the idea of including a third-party dll in my application. So I though and I had the idea of embedding my controls in toolbars.
Can you give me an example of how to put a custom control in a toolbar. Or is this impossible? Help would be greatly appreciated.
|
|
|
|
|
So, I'd like this to work:
Thread t = new Thread(new ThreadStart(StartProcess));<br />
int i = 0;<br />
int numThreads = 10;<br />
while (i <= numThreads)<br />
{<br />
t.Start();<br />
i++;<br />
}<br />
But I know it doesn't .
Can anyone tell me how to get this working?
|
|
|
|
|
Keep in mind you don't want to do something like this so I'm not sure what value there is in showing you.
int i = 0;<br />
int numThreads = 10;<br />
while (i <= numThreads)<br />
{<br />
Thread t = new Thread(new ThreadStart(StartProcess));<br />
t.Start();<br />
i++;<br />
}
led mike
|
|
|
|
|
I would like to be able to dynamically identify how many threads I want the the application to use.
The problem is that the function is blocking, so I need a new thread for each function.
|
|
|
|
|
Use an array containing the threads you wish to create. Also use the QueueUserWorkItem instead (from the threadpool) it is faster.
Also, test of mine of confirmed that using this scenario rarely works faster unless the threads are waiting on different resources.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
miles.smith wrote: I would like to be able to dynamically identify how many threads I want the the application to use.
Based on what? What criteria do you think you will be using to make that determination?
miles.smith wrote: so I need a new thread for each function.
No, what you need is to do some reading on the subject of multi-thread application development. I don't know what current sources there are but years ago I found Advanced Windows by Richter to be a valuable resource on the subject of multi-threading
led mike
|
|
|
|
|
Okay, I'll go do some reading up on that. It seems like I'm not understanding what my requirements are!
Thanks.
|
|
|
|
|
miles.smith wrote: Okay, I'll go do some reading up on that.
Excellent decision, there is hope for you. Don't expect miracles though. The subject can be rather elusive. Take your time, it's worth getting it right.
led mike
|
|
|
|
|
Hello,
Can anybody give me link or provide sample source as how to let EMAB know about the newly added custom Exception Handler class without adding it to configuration file?
Enterprise library depends on Configuration file settings to know about any new custom Exception Handlers, which as a developer we need to configure (add using EL Configuration Console). But i don't want to do that, i just want EMAB to pickup the Class implementing IExceptionHandler from current Assembly.
Thanks
|
|
|
|
|
hi guys i was wondering if you could help me out please, i have been stuck at this for a few days...
I am using the Intel Mobile SDK to monitor Power and Cononnectivty, i can monitor them and log the results in the console, but i would like to migrate it to log in a text box in the form?
below is my program, could sumbody help me out please, or if sumbody could point in the right direction, many thanks.
using System;
using System.Threading;
using Intel.Mobile.Base;
using Intel.Mobile.Battery;
using Intel.Mobile.Context;
namespace Sample
{
public class ConnectEventSample
{
internal static bool LoopFlag = true;
internal static readonly System.Object Mutex = new System.Object();
[MTAThread]
static void Main(string[] args)
{
try
{
ContextClass myClass = new ContextClass();
PowerInstance myInstance = (PowerInstance)myClass.GetInstance("Power");
ConnectivityInstance myInstance2 = (ConnectivityInstance)myClass.GetInstance("Connectivity");
Observer ConnectObserver = new ConnectObserver();
Observer DisconnectObserver = new DisconnectObserver();
Observer ConnectObserver2 = new ConnectObserver2();
Observer DisconnectObserver2 = new DisconnectObserver2();
myInstance.ExternallyPowered.AddObserver(ConnectObserver);
myInstance.InternallyPowered.AddObserver(DisconnectObserver);
myInstance2.Connected.AddObserver(ConnectObserver2);
myInstance2.Disconnected.AddObserver(DisconnectObserver2);
Console.WriteLine("------------ Waiting for Event ------------");
bool bContinue;
do
{
// Wait for Connect event.
// The network cable may be plugged in to trigger this event.
// yield a few CPU cycles
//Thread.Sleep(500);
lock (Mutex)
{
bContinue = LoopFlag;
}
}
while (bContinue == true);
//myInstance.ExternallyPowered.AddObserver(ConnectObserver);
//myInstance.InternallyPowered.AddObserver(DisconnectObserver);
//myInstance2.Connected.AddObserver(ConnectObserver2);
//myInstance2.Disconnected.AddObserver(DisconnectObserver2);
myInstance.ExternallyPowered.RemoveObserver(ConnectObserver);
myInstance.InternallyPowered.RemoveObserver(DisconnectObserver);
myInstance2.Connected.RemoveObserver(ConnectObserver2);
myInstance2.Disconnected.RemoveObserver(DisconnectObserver2);
ConnectObserver.Close();
DisconnectObserver.Close();
ConnectObserver2.Close();
DisconnectObserver2.Close();
}
catch (IntelMobileException ex)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + ex.Message);
Console.WriteLine("Source: " + ex.Source);
Console.WriteLine("Target Site: " + ex.TargetSite);
Console.WriteLine("Error Code: " + ex.ErrorCode);
Console.WriteLine("Detailed Error Info: " + ex.DetailErrorInfo);
}
catch ( Exception e)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Target Site: " + e.TargetSite);
}
//Console.Write("Press 'Enter' to exit...");
//Console.Read();
}
}
internal class ConnectObserver : Observer
{
public override void Notify(Event ev)
{
try
{
if (ev.GetType() == EventBase.EventType.eExternallyPowered)
//Console.WriteLine("{0} Connected event occurred for {1}", ev.GetTSstring(), ev.GetOriginator().GetType());
Console.WriteLine("AC Adapter Connected - Running on External Power " + DateTime.Now);
}
catch (IntelMobileException ex)
{
Console.WriteLine(ex);
}
catch (Exception e)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Target Site: " + e.TargetSite);
}
// Reset flag to exit event wait loop
//lock (ConnectEventSample.Mutex)
//{
// ConnectEventSample.LoopFlag = false;
//}
}
}
internal class DisconnectObserver : Observer
{
public override void Notify(Event ev)
{
try
{
if (ev.GetType() == EventBase.EventType.eInternallyPowered)
//Console.WriteLine("{0} Connected event occurred for {1}", ev.GetTSstring(), ev.GetOriginator().GetType());
Console.WriteLine("AC Adapter Disconncted - Running on battery " + DateTime.Now);
}
catch (IntelMobileException ex)
{
Console.WriteLine(ex);
}
catch (Exception e)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Target Site: " + e.TargetSite);
}
// Reset flag to exit event wait loop
//lock (ConnectEventSample.Mutex)
//{
// ConnectEventSample.LoopFlag = false;
//}
}
}
internal class ConnectObserver2 : Observer
{
public override void Notify(Event ev)
{
try
{
if (ev.GetType() == EventBase.EventType.eConnected)
{
//Console.WriteLine("{0} Disconnected event occurred for {1}", ev.GetTSstring(), ev.GetOriginator().GetType());
Console.WriteLine("Connected to Network at " + DateTime.Now);
}
}
catch (IntelMobileException ex)
{
Console.WriteLine(ex);
}
catch (Exception e)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Target Site: " + e.TargetSite);
}
}
}
internal class DisconnectObserver2 : Observer
{
public override void Notify(Event ev)
{
try
{
if (ev.GetType() == EventBase.EventType.eDisconnected)
{
//Console.WriteLine("{0} Disconnected event occurred for {1}", ev.GetTSstring(), ev.GetOriginator().GetType());
Console.WriteLine("Disconnected from Network at " + DateTime.Now);
}
}
catch (IntelMobileException ex)
{
Console.WriteLine(ex);
}
catch (Exception e)
{
Console.WriteLine("------------ Exception Occurred ------------");
Console.WriteLine("Message: " + e.Message);
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Target Site: " + e.TargetSite);
}
}
}
}
|
|
|
|
|
Be aware that adding to a textbox with alot of text in it is a very slow operation. You'll want to keep the buffer displayed in it very short to keep CPU usage reasonable.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|