|
Is there a way I can extract the extact data type strings but sql via ADO.NET.
I need to know the exact name of the data type from sql.
I tried creating a data table and filling it, then examining the columns. But, only gives me a .net data type. For instance, smalldatetime is converted to DateTime.
I need to know what it is before the conversion.
thanks
nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
you could try to perform a query which shows you the tables structure
( MySQL: desc Tablename; - Firebird: show table Tablename; ) and parse the
result in your programm. That way you would get the name of the datatypes used by your database.
|
|
|
|
|
Hi guys,
I have a ToolStrip control that is not redrawing properly. It seems to not be receiving a paint message when it should (ie if I bring any other window in front of it, it doesn't redraw). This is the structure it sits in:
- SplitContainer
- TabControl
- TabPage
- ToolStripContainer
- ToolStrip
It also doesn't redraw consistently when I switch between TabPages. Has anyone come across this before?
Many thanks,
Simon
PS This problem is occurring in a Windows Forms application for the desktop.
|
|
|
|
|
Hello
Yes. ToolStip control isn't supposed to redraw itself without having the focus- AFAIK-. This is normal.
Regards
|
|
|
|
|
Hi Nader,
Thanks for your reply. However, it does seem a bit odd because when I drag a window in front of Outlook the toolstrips there redraw perfectly well. Is there an obvious technique I should be aware of for forcing a redraw?
Many thanks,
Simon
|
|
|
|
|
Hello
It looks like I got your question all wrong!! Now I get what you mean.
Why doesn't your ToolStrip draw itself?? Doesn't it fire paint events?
To demonstrate that, I made the same cascade that you did, then I added a ListBox, and then the following code for each paint event in the cascade:
private void toolStripButton1_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("Button Paint");
}
private void toolStrip1_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("ToolStrip Paint");
}
private void toolStripContainer1_ContentPanel_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("Container Paint");
}
The listbox addes the item in the same order as the paint events should be fired. Al the Paint events are fired appropriately.
Try this demo in your code to see if the paint events are fired or not.
Regards
|
|
|
|
|
Thanks for your time on this Nader. I was hoping someone would say "Oh, that's a common problem and you just need to set property x". I was trying to avoid a full on investigation as I'm on a schedule with this thing. However, I will use your code and start digging into the problem to find out what's going on.
Many thanks again,
Simon
|
|
|
|
|
Am trying to dynamically build a tab, multipage and pageview
protected Microsoft.Web.UI.WebControls.TabStrip tc;
protected Microsoft.Web.UI.WebControls.MultiPage mp;
protected System.Web.UI.WebControls.Label txt;
Microsoft.Web.UI.WebControls.Tab tab=new Microsoft.Web.UI.WebControls.Tab();
Microsoft.Web.UI.WebControls.PageView pv= new Microsoft.Web.UI.WebControls.PageView();
//Am building a control here and adding it to pv
System.Web.UI.WebControls.TextBox txt= new TextBox();
txt.Text = "Microsoft";
pv.Controls.Add(txt);
pv.ID = id.ToString();
tab.TargetID = pv.ID;
Error: TargetID does not point to a valid PageView
the tab.TargetID has to be set to pv.(something).
can somebody help me on this?
rmr
rmr
|
|
|
|
|
Hello
First do not repost your question in the same forum even if you didn't get any answer. It's very rude. Delete the previous thread.
Second, to get an answer to your question you need to post this in the ASP forum not here.
Regards
|
|
|
|
|
Hello,
Its not that I dont know the basics of posting on forums, I needed to change the subject so that someone can help me out, I posted it again. Thanks for your advice and if you had helped me out, I would have told you double thanks.
rmr
|
|
|
|
|
Hello
I'd have happily helped you if I were an expert in ASP. There is a difference between C# and ASP. All I were capable of doing is pointing you to the right direction.
Regards
|
|
|
|
|
I create multiple STA threads and start them. Once I have started all the threads in my main thread I need to wait till all of them are done.
To wait I tried
WaitHandle.WaitAll() ----- returns exception
Tried
waitEvent.waitOne()
and thread.Join()
In above case some times my main thread slips through Join\waitOne(). (i.e. main thread does not wait till all other threads are done)
Please advice how to implement this?
My sample code is as below
Main()
{
...
...
ArrayList myThreadClass = new ArrayList(3);
ArrayList threads = new ArrayList(3);
for(int i = 0 ; i< 3;i++)
{
ThreadClass thClass = new ThreadClass();
myThreadClass.Add(thClass);
Thread myThread = new Thread( new ThreadStart(thClass.threadMethod));
myThread.ApartmentState = ApartmentState.STA;
threads.Add(myThread);
((Thread)threads[i]).Start();
}
for(int k = 0;k<3;k++)
{
((Thread)threads[k]).Join();
}
.....
.....
} //Main Ends
Some more info
In my thread method I do some COM calls and make some callls Writeline to StreamWriter
Sandeep Naik
|
|
|
|
|
Hello
You can go through your threads using a loop and check the IsAlive property of each
bool Finished = false;
while(!Finished)
{
Finished = true;
foreach(Thread T in Threads)
{
if(T.IsAlive)
Finished = false;
}
Thread.Sleep(100)
}
Otherwise you can check the ThreadState property
Regards
|
|
|
|
|
Will I be blocking message pump here ?
Sandeep Naik
|
|
|
|
|
I tried something like this and it works with some of my testing ..
Do you think if this correct ? or will there be any issues with this
for(int temp = 0; temp <threadcount;temp++)
{
thread mythread="(Thread)GRDumpThread[temp];
if(myThread.IsAlive)
{
waitEvents[temp].WaitOne();
}
}"
<div="" class="ForumSig">Sandeep Naik
|
|
|
|
|
Hello
Your code segments are inconsistent and somehow don't add up!! For example what is GRDumpThread??
Anyway, if you want to use WaitHandle class, you should register your threads in ther ThreadPool queue. Take a look at this example taken from MSDN:
using System;
using System.Threading;
public sealed class App
{
static WaitHandle[] waitHandles = new WaitHandle[]
{
new AutoResetEvent(false),
new AutoResetEvent(false)
};
static Random r = new Random();
static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine("Main thread is waiting for BOTH tasks to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
WaitHandle.WaitAll(waitHandles);
Console.WriteLine("Both tasks are completed (time waited={0})",
(DateTime.Now - dt).TotalMilliseconds);
dt = DateTime.Now;
Console.WriteLine();
Console.WriteLine("The main thread is waiting for either task to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
int index = WaitHandle.WaitAny(waitHandles);
Console.WriteLine("Task {0} finished first (time waited={1}).",
index + 1, (DateTime.Now - dt).TotalMilliseconds);
}
static void DoTask(Object state)
{
AutoResetEvent are = (AutoResetEvent) state;
int time = 1000 * r.Next(2, 10);
Console.WriteLine("Performing a task for {0} milliseconds.", time);
Thread.Sleep(time);
are.Set();
}
}
Whatever you use, just make it work.
And for the method I posted earlier, yes it blocks your message pump.
Regards
|
|
|
|
|
Thanks for all your help... It was very use full
Sandeep Naik
|
|
|
|
|
Hello,
does anyone know how to make a true copy of the reference object to the new variable as if it was a value type?
An object is passed to my DLL from the application and I need to compare the object's contents between the calls.
Thanks much,
Michal
|
|
|
|
|
Hello
This epends on what type of reference object you are talking about. Each class implements a "Cloning" method accordingly. Some well known way of copying reference types -if available- are:
1- All classes derived from System.Object inherit a protected method called MemberwiseClone() . Remember this is protected, so you could use it if you inherit from that class only.
2- Some reference types override the = operator to perform copying of data rather than references. Known example is the System.String class.
3- Other types include a copy constructor where you could construct an object from the values of another.
Again if all the above is not available in your reference type, then you'll just have to make your own way of copying public members.
Regards
|
|
|
|
|
Hello,
thanks. Unfortunately, the object passed to my DLL doesn't implement any of the cloning methods so I will need to compare the object properties by storing them and comparing them one by one.
Thanks.
Michal
|
|
|
|
|
At the moment I have the following classes :
Record ( which is the superclass )
- MessageHeaderRecord ( the superclass for the next classes ) :
- InfosRecord ( the class for the I tag
representing the informations from text )
- CommentRecord
- OrderRecord
- ResultsRecord
- TerminatorRecord
For each of this classes I have a corresponding class (MessageHeaderRecordFields ,...) in which I created the fields to put the infos from the file.
So far so good ...
MessageHeaderRecord beeing the superclass for the rest of classes I put inside of it a generic List :
private List m_Infos = new List()
internal List Infos
{
get
{
return m_Infos;
}
}
and the constructor is
internal MessageHeaderRecord()
{
RecordType = RecordType.MessageHeaderRecord;
m_Fields = new MessageHeaderRecordFields(); //
}
I did this because I want to access the objects as follows :
Message MyMessage = new Message();
MyMessage.Infos[3].Fields.SequenceNumber = "1";
MyMessage.Infos[3].Fields.InfoName.LastName = "John";
// Create a new info
int nInfoIndex = MyMessage.AddNewInformation(); (*1)
// Set the info specific data such as name, age, etc. for the info we just addded
MyMessage.Infos[nInfoIndex].Fields.InfoName.LastName = "John";
// Add an order record for this patient
int nOrderIndex = MyMessage.Infos[nInfoIndex].AddNewOrder(); (*2)
// Set the order specific information for the new order
MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].Fields.OrderID = "11";
// Add a comment to this order
MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].AddNewComment(); (*3)
// Set the text for the new comment
MyMessage.Infos[nInfoIndex].Orders [nOrderIndex].Commment.Fields.CommentText = "I am a comment.";
// Add a Result to this order
nResultIndex = MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].AddNewResult();
// Set the new result's data
MyMessage.Infos[nPatientIndex].Orders[nOrderIndex].Results[nResultIndex].Fields.SequenceNumber = "333"; (*4)
So my problems redefined would be
(*1) - In which class to put the AddNewInformation() method
(*2) - In which class to put the Orders List and where to put the AddNewOrder() method
(*3) - In which class to put the Comment List and where to put the AddNewComment() method
(*4) - Same with Results List and AddNewResults() method
Please help me with this issues because I really cant figure them out.
Thank you in advance
|
|
|
|
|
Maybe I'm getting this wrong, but from what I understood, all the Add* methods are a bit reduntant if you don't do any special initialization inside them. For example in *1:
<br />
int nInfoIndex = MyMessage.AddNewInformation(); (*1)<br />
MyMessage.Infos[nInfoIndex].Fields.InfoName.LastName = "John";<br />
Could just be done like:
<br />
Info information = new Info (firstName, lastName, ...);<br />
MyMessage.Infos.Add (Info);<br />
While this doesn't retrieve the index so you can change afterwards, you can setup the class beforehand and then add it.
This can be used for all the other questions as far I understand.
If this wasn't what you were asking, then my apoligies.
Bruno Sousa
Software Consultant
http://www.luasys.com
|
|
|
|
|
Hey, simple question really.. i guess it could be done either way but i'm just wondering what the BEST way to do this is.
Basically the problem is very simple. all i want to do is pass a string from one application to another... just one direction. I'm wondering what the quickest and best way to go about this is. Should i just open up a TCP connection using windows sockets and pass it that way or should i try using remoting?
I'm sure the solution is simple but i don't want to do anything overkill just to pass a string
Thanks!
|
|
|
|
|
Socket. Anything else would be overkill in your case.
Best,
Jun
|
|
|
|
|
a web service would take about 3 minutes to create and publish
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|