|
On program startup, you could query the schema for all your tables. Build class to hold information like field names, value types and lengths.
Here's some of my code, I'm sure most people here can come up with something more effecient . The tabbing is getting killed but you get the idea.
Mine looks something like this
<br />
namespace DBWrapper<br />
{<br />
public class FieldInfo<br />
{<br />
private string strField = string.Empty;<br />
private string strType = string.Empty;<br />
private int nLen = 0;<br />
<br />
public string FieldName<br />
{<br />
get { return strField; }<br />
set { strField = value; }<br />
}<br />
<br />
public string FieldType<br />
{<br />
get { return strType; }<br />
set { strType = value; }<br />
}<br />
<br />
public int FieldLen<br />
{<br />
get { return nLen; }<br />
set { nLen = value; }<br />
}<br />
}<br />
<br />
public class TableData : List<FieldInfo><br />
{<br />
public FieldInfo Get(string strFieldName)<br />
{<br />
FieldInfo retFieldInfo = new FieldInfo();<br />
<br />
foreach (FieldInfo fiInfo in this)<br />
{<br />
if (string.Compare(fiInfo.FieldName, strFieldName, true) == 0)<br />
return fiInfo;<br />
}<br />
<br />
return new FieldInfo();<br />
}<br />
<br />
}<br />
}
<br />
To get the schema info I use this (I think this is half my code and half somebody elses but it's been so long since I touched it I don't remember)<br />
<br />
protected bool GetTableSchema(out DataTable dtSchema)<br />
{<br />
dtSchema = new DataTable();<br />
SqlCommand dbCommand = new SqlCommand();<br />
SqlDataReader dbReader;<br />
bool bRetValue;<br />
<br />
if (!OpenDatabase())<br />
return false;<br />
<br />
try<br />
{<br />
dbCommand.CommandText = "SELECT * FROM " + m_strTableName;<br />
dbCommand.Connection = m_DBConnection;<br />
dbReader = dbCommand.ExecuteReader(CommandBehavior.KeyInfo);<br />
dtSchema = dbReader.GetSchemaTable();<br />
bRetValue = true;<br />
}<br />
catch (Exception ex)<br />
{<br />
string strErrorMessage = "Error Getting Table Schema " + dbCommand.CommandText + "\r\nMsg: " +<br />
ex.Message;<br />
#if DEBUG<br />
Console.WriteLine(strErrorMessage);<br />
#else<br />
m_LogHandler.WriteLogLine(strErrorMessage);<br />
#endif<br />
bRetValue = false;<br />
}<br />
finally<br />
{<br />
CloseDatabase();<br />
dbCommand.Dispose();<br />
}<br />
<br />
return bRetValue;<br />
}
|
|
|
|
|
these objects can just be templated and code generated ... there are code generators out there that can use db schemas as a datasource but I've always just rolled my own code generator.
|
|
|
|
|
Hey Everybody!!!
I'm having the weirdest problem ever! I really can't figure it out!
I wrote a crawler, and I am downloading using DownloadData() of the WebClient class.
I'm starting to crawl when all the time I am getting a WebException with the message "The operation has timed out".
I can easily surf to this page using my browser, moreover, when I try to download ONLY this page using the DownloadData(), the page is being downloaded without any problems!!!
I keep on getting this exception specifically on this page.
I'm really stuck with it !!!
Help anyone????
Thanks in advance !!!
|
|
|
|
|
Here's a wag.... your crawler may be being detect as a bot by bot prevention systems running on that server.
|
|
|
|
|
Thanks for the QUICK reply , but I thought about it...
I tried to prevent it using Thread.sleep(1000) AND changing the user-agent to IE's user-agent.
but it doesn't work
maybe it checks using a different method, but I can't really think of one....
|
|
|
|
|
Green Fuze wrote: I thought about it...
I tried to prevent it using Thread.sleep(1000)
I don't know what kind of response you are eliciting with that statement but I am going to choose to say "no comment".
|
|
|
|
|
you wrote that maybe my bot is being detected by some kind of a bot detection. So, from what people told me, too many HTTP requests in an interval might point out that it is a bot, Therefore by using Thread.sleep, I thought maybe I would cause my bot to perform less HTTP Requests, thus making it look like it is a human, and not a bot. anyway, it doesn't work... so....
|
|
|
|
|
Green Fuze wrote: thus making it look like it is a human
how did you make it look human by requesting a page every second? You think real people do that?
|
|
|
|
|
I can't remember off the top of my head but there is a way to send data about how you are accessing the data, such as what type of user, browser capability ect. Look into how to set that and it may fix your problem.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
Or you might have wrong proxy address in the config file.
|
|
|
|
|
Greetings,
My question is: how is using EventsHelper.FireAsync() different from using EventsHelper.Fire() BUT having the listener's event handler spawn a new thread to do the work?
In my program, I have a data feed coming in and I have a separate form that has a DataGridView on it. Each time a message comes in (they come in very rapidly) I fire an event and the handler (which exists on the DataGridView's form) adds a row to the DataGridView.
Approach #1: use EventsHelper.FireAsync() to fire the events as they come in. This is nice because the slowness of adding rows to the DataGridView control doesn't slow down the incoming data feed AT ALL -- meaning, if there were other listeners to this event, their performance wouldn't suffer from the slow DataGridView. HOWEVER, this approach doesn't work because of the asynchronous nature, the rows aren't necessarily added in order (message 3 might be processed/added to the DataGridView before messages 1 and 2).
Approach #2: use EventsHelper.Fire() (the synchronous version), and in the event handler, spawn a BackgroundWorker that adds the message to the DataGridView. I don't like this approach because then EVERY handler of this event is going to have to do all this extra work, but I figured it was the only way I could ensure the messages (events) would be received in order. However what I noticed is this approach (spawning the BackgroundWorker thread) doesn't really give a speed improvement over simply doing ALL the work in the same event thread.
Why isn't approach #2, with a BackgroundWorker in the ONLY event handler as fast as approach #1?
I love the speed EventsHelper.FireAsync provides, but I need to maintain order of the events. If anyone has any advice, I'm all ears.
Thanks in advance!
RL
|
|
|
|
|
Well, I can only guess what EventsHelper is, but if I were to use my psychic debugging skills, I'd guess we're talking about something that calls delegates/events asynchronously.
To answer your question, my guess would be that EventsHelper.FireAsync may use a single background thread, whereas having the handlers each have their own has many threads. Just a wild guess though.
Here's what I recommend. When the data feed comes in, don't fire your event. Instead, have a queue, and every time data comes in, queue up a function that raises the event or actually updates the data, whatever you need it to do.
Combine that with Application.Idle event handler. This handler should check the queue for any queued up stuff, and if so, execute it. That way, you'll never flood your UI thread with the incoming data, the DataGridView will remain responsive, and you'll get your data in the correct order.
|
|
|
|
|
HI,
i Have An APP that when u want to save something
i like to show the user these field's :
Auther,Description (like u got in windows)
Can i Create A File(The Format for now is .txt)
And Set his Properies of Auther,Description
And if so How?
A link would be Usfull (THANKS)
Have Fun
Never forget it
|
|
|
|
|
Try this : http://www.codeproject.com/cs/files/detailedfileinfo.asp
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
THANKS
But I stiil trying To figure how to create the file and it's Properies
I'm Tring Assembly, is it the right way ?
Have Fun
Never forget it
|
|
|
|
|
Hello everyone,
I am currently using Visual Studio 2005 Express Edition. I would like to get my hands on Visual Studio 2005 Standard Edition. If I am not mistaken there should be a Trial Version available. I have been searching and searching and searching but unfortunatly, I am unable to find the Trial Version online.
Can anyone tell me where I can find a Trial Version of Visual Studio 2005 Standard Edition?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
I don't know anything about it but it seems possible that the Express Edition is the trial edition, yes?
|
|
|
|
|
The Express Edition is not a trial edition. Its free .(and = 0).
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
Hello,
Thanx for the respond. Yes, the Express Edition is the Free one, but surly, the Standard Edition should have a Trial Edition. After all the Profesional Edition has a 90Days Trial period.
Thank you again and have a great day.
Khoramdin
|
|
|
|
|
Khoramdin wrote: the Standard Edition should have a Trial Edition.
not sure what you mean by "should". They have what the have, period. I would imagine that if you can't find it anywhere it doesn't exist. It's not like you're looking for something produced by a guy out of his garage.
|
|
|
|
|
Hello Mike,
What can I say! You are correct! Thank for your help, mate.
Have a great day
Khoramdin
|
|
|
|
|
You can't find it because there is no time-limited trial version for Standard or Pro Editions. There is only a trial version of the Team Suite Edition, found here[^].
|
|
|
|
|
Hello Dave,
Thanx mate.
Have a great day.
Khoramdin
|
|
|
|
|
How to connect hardware device to my C# program , such as Camera , or any device (connect by port)
CS
|
|
|
|