|
|
OK, I love to learn new and better ways to do things, but this just doesn't seem one of them.
I'm originally from the Java camp so I've used straight DB code such as hard coded calls to the database and ORM tools like Hibernate. I've been working in VB for the past 5 years on various projects and have used similar techniques here as well.
I am working on a fairly large project and decided to use strongly typed db access such as what is taught in these fairly popular tutorials:
http://www.asp.net/learn/data-access/[^]
Boy am I getting a headache. It seems to me that the only benefits I get are IntelliSense and compile time checking. IntelliSense wasn't available before strongly typed database code so this is more of a convenience than any real need. Compile time checking is nice but I've already had several errors that are not caught until runtime. These errors largely deal with enforcing constraints when filling a DataTable using a standard DataAdapter. Most of these errors are extremely trivial, do not interfere with my actual code and would never have been brought to my attention without strongly typed db code.
So here is what I see as the major negative. I feel like I am getting much more code dependence rather than the current shift towards independence. This project largely works with data from a vendor database. If they ever update their schema (which can be as often as once a week) my app will break, even if they simply change a field from varchar(10) to varchar(12).
I'm starting to lean towards either rolling my own db code or using NHibernate again. Also, LINQ seems to be a departure from this strategy as well.
Does anyone else have any comments? Have any of you used strongly typed db code on a large project and found it to be indispensable? What am I missing?
Thanks!
Matt Penner
|
|
|
|
|
We use XPO[^] here at work. We had done it "by hand" previously, and XPO saves us tons of time.
That said, it's not a walk in the park. There are still issues, such as the db scheme change breakings (although XPO handles most schema changes automatically OK).
Most O/R mappers give you database independence; your code will work with MS SQL Server, MySQL, Oracle, Access, whatever.
Overall, I'm certainly glad we have an O/R mapper. It could be better, but it's far, far better than doing it by hand.
|
|
|
|
|
Judah Himango wrote: It could be better
Yes it could. As a work around, don't do development that uses databases... actually don't do development that uses data at all.... oh what heck just don't do software development. Hey maybe the circus that's in town could use another clown?
|
|
|
|
|
led mike wrote: Hey maybe the circus that's in town could use another clown?
Sorry, I went there last night and took the LAST CLOWN JOB IN TOWN. Ha. Take that, you clown-wannabe.
|
|
|
|
|
Judah Himango wrote: you clown-wannabe.
Not really... I was just clowning around.
|
|
|
|
|
Yay XPO. I like XPO - even with its quirks.
|
|
|
|
|
MattPenner wrote: What am I missing?
This requirement of yours seems to stand out... to me anyway.
MattPenner wrote: If they ever update their schema (which can be as often as once a week)
That seems to be a significant requirement to me. Based on that requirement I would not expect standard database techniques to sufficiently meet that requirement. It might warrant specific custom design to accomplish flexibility and extensibility.
|
|
|
|
|
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
|
|
|
|