I want some Moore

Blog about stuff and things and stuff. Mostly about SQL server and .Net
posts - 191, comments - 2118, trackbacks - 33

My Links

SQLTeam.com Links

News

Hi! My name is 
Mladen Prajdić  I'm from Slovenia and I'm currently working as a .Net (C#) and SQL Server developer. I'm a MCP and MCTS for SQL Server. I also speak at local user group meetings and conferences like NT Conference 
Welcome to my blog.

Search this Blog

My Blog Feed via Email


Users Online: who's online

Article Categories

Archives

Post Categories

Cool software

Other Blogs

Other stuff

SQL stuff

VS 2k5 autogenerated code gem

A coworker found this in code generated by Visual Studio 2005:

this.sqlSelectCommand2.CommandText = "SELECT columnName1, columnName2, columnName3, columnN" + 
"ame4, columnName5, columnName6 FROM MyViewFromMa" +
"nyTables"

Searching for MyViewFromManyTables is beautifull...

Refactor that!!

Print | posted on Monday, November 27, 2006 11:34 AM

Feedback

# re: VS 2k5 autogenerated code gem

Another good reason to use the Command object and execute a stored procedure :).
11/27/2006 4:58 PM | Jon

# re: VS 2k5 autogenerated code gem

Autogenerated code isn't there for refactoring beacuse - it is autogenerated. If you want to have a strong typed database access then you need another approach.
Jon: both approaches do use command object and both can use a stored procedure.

I agree though that VS designers aren't suitable for larger applications (I tend to avoid them except when I have to create a quick sample).
11/28/2006 10:12 AM | Miha Markic

# re: VS 2k5 autogenerated code gem

well if i change the views name in sql server i can use SQL refactor to rename/refactor the whole db it and it's great. and when i want to change it in code it's really fun to find :))

but i agree with you Miha.
11/28/2006 10:28 AM | Mladen

# re: VS 2k5 autogenerated code gem

Miha my point was your procedure name will not be (hopefully) the length of that SQL string. You avoid all the SELECT blah1, blah2 FROM...+... etc.
11/28/2006 1:30 PM | Jon

# re: VS 2k5 autogenerated code gem

Mladen: Yes, IMO those designers are not meant to work on larger projects.

Jon: I see. :-)
11/28/2006 4:10 PM | Miha Markic

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 8 and 2 and type the answer here:

Powered by: