Posts

Showing posts from March, 2008

T-SQL Drop Stored Procs - NetTiers version via cursor

Image
After generating all CRUD procs with several different naming prefixes, my database was looking messy. So I knew what I wanted to produce but I needed to get rid of all these other procs. So how to quickly drop all the procs. Wayne said he had a codesmith template for it but I couldn't wait. I google'd and found another person that had the same problem after a heavy CodeSmith NetTiers session. His method was not too different from my post from yesterday . I did my final gen of procs via NetTiers but instead of going into the database, sent them to a file. I opened the file to find the following code which should have been both obvious in that NetTiers would need it and where I should look for it: BEGIN DECLARE @procedureName SYSNAME DECLARE c CURSOR FOR SELECT name FROM sysobjects WHERE type = 'P' AND objectproperty ( id , 'IsMSShipped' ) = 0 AND name LIKE 'NetTiers_%' AND name NOT LIKE 'WW_{0}_%' OPEN c FETCH NEXT

T-SQL Drop Stored Procs - query window

Image
In Sql server query window, execute query that selects all stored procedures with the prefix you want (such as procedures that start with 'cust'): SELECT 'DROP PROCEDURE ' + Name FROM sys.objects WHERE type in ( N 'P' , N 'PC' ) and name like 'cust_%'   Right-click the query window and set results to text. This gives you a results window with a single column of drop prodecures. Select all the text, copy to a new query window and execute.

CodeSmith NetTiers Best Practices

Image
After using NetTiers for a couple of weeks now, here are some suggestions for usage: 1) Use NetTiers like any third party library. Build it and include the libraries. Do not alter code inside generated libraries unless mission critical. I also use the Microsoft.Patterns library. They ship the code but I don't alter it, I just use the built libraries.  2) Prefix the library namespace with NetTiers so that the generated libraries look like NetTiers.Entities, NetTiers.Data, etc. 3) If you use NetTiers to generate your CRUD, set the ProcedurePrefix value to NetTiers_. When you are looking through a million procs, it easier to pass a whole section based on alphabetical sorting. If you use AspNet Membership, you will be accustomed to this naming schema as those procs are prefixed with aspnet_ 4) If you create your own procs, prefix those procs to something that you won't confuse with any other library's procs, such as 'cust' for custom. Of cource, IncludeCustoms is

CodeSmith NetTiers discovery of a custom stored procedure

Image
I have a table with two FKs. NetTiers creates a stored proc for the PK as well as a stored proc for each FK however it doesn't create a stored proc that uses both FKs as the IN params. So I need to create this in a way that NetTiers can discover it and build the code objects to support it. First I have to create the stored proc with a discoverable name. This requires several settings in the NetTiers template. First, that I want custom stored procs discovered so IncludeCustoms =true. Second, I want any stored procs to have a naming prefix so ProcedurePrefix =usp. Third, I need to handle the actual name of the stored proc. NetTiers uses discovery based on a template where the zeroth parm is the table name and the first parm is the Procedure Prefix so CustomProcedureStartsWith ={1}_cust_{0}_. The remainder of the stored proc name is irrelevant but what is returned is very important. I usually return all columns which is NetTiers default object handling. If I choose not to include all

How do you GridView?

Image
I've been stuck in build hell for a week but now back to code. I want data that would normally be a JOIN between two tables. It's a join between ProfileProperties and UserProfileValues. But since I'm using NetTiers for my middle tier and I just want to get going, I'm writing a subpar GridView. The first column is pulled from a select of all profile properties provided by my ProfileDataSourceObject given to me by NetTiers. The second column is a function with a param of the profile property. The function grabs the user from the context and the profile property from the param, then determines what (if any) value has been set. This is not how I should do things. And since I usually don't do it this way, I'm sort of having to relearn some aspx syntax on how to do this. I much prefer to have SQL return this data and just format it in the GridView. SQL doesn't change everytime Microsoft releases a new version of Visual Studio. How would you do this?  

More NetTiers configuration

Image
Building Separately Building the NetTiers projects are getting tedious inside my main web app solution. I'm now building them separately and just moving into my main solution as references to each project. While I'm making so many database design changes, that is the best option. When the table designs and relationships are in place, I may move the .NetTiers projects back into my main solution. Table Standards One of my tables had the 'name' column as the last column as opposed to the column immediately following all the id,pk,fk columns. NetTiers decided only the next column after the id,pk,fk must be the most meaningful. It used this column which was not the name column but some non-determining column as the value for drop down lists in it's web admin site. So for everytable who had this table as a fk, this non-determining column populated as drop down list. So I had to change that in the database then regenerate the NetTiers projects. NetTiers Admin site not

ID ten T error (ID10T): Check the data

Image
I finally got NetTiers up and running and wanted to see my data. I choose the last data table I designed. I just spent an hour trying to use NetTiers to see my data with their version of a DataSource for that table. I finally figured out the table has nothing to see. Ugh!!!   The last hiccups were web.config issues. Easily found answer on google.   So NetTiers templates are configured. NetTiers projects are integrated into my solution with several other projects. Everything builds. I can call the highest level web and data NetTiers objects. Now time to check in to source control. I'm checking in entire NetTiers template tree, all generated files from the templates, and all changes to my web app so that I can use NetTiers. I don't build directly into my project tree so I have to copy the generated files over. This is a failsafe for now that I expect to eventually remove. I already have a change to a table to make so I'll figure out how I want that process to go.  

Source Safe Control from Visual Studio 2005

Image
Apparently, Source Safe and Visual Studio have to have the projects as sibling nodes both on the hard drive and in source safe. The source safe names must match the Visual Studio project names. So after dinking with both to try to get them to talk to each other, I scraped my current visual studio node and reorganized my hard drive directories so that all projects are siblings and the solution files are in the parent directory. Then I tried to tie Visual Studio to Source Safe by hand. Since it still didn't work, I renamed my visual studio parent node just to save it instead of deleting. Then I had the Visual Studio solution add all the projects to source safe. This is definitely not the recommended method but everything is still small. One of these days, I just code. And code. And code.    

NetTiers Template Integration with Existing Solution

Image
I've been working for two hours to get my existing NetTiers CodeSmith Template to generate the files the way I need them. The NetTiers template gets 90% there out of the box but the template tips for each line item are sometimes obsure or require another lineitem to be TRUE. Then there is a fair bit of user error such as what to name the libraries created by the template, the directory they should be sent to. One error right out of the box is the LibraryPath value. It's inconviently stuffed in the Advanced CRUD section and just says Reference. After the projects try to build but fail but to the reference libraries not found, I figured out what was going on. NetTiers generates the web service and client pieces which I keep in the template but don't use. No I'm working on making sure my project library which includes all the libraries built by NetTiers CodeSmith has the right hierarchy in terms of having functions where I would expect them to be. I'm sure at some p

So You Want Your Own Business Website (SYWYOW): Where do you begin?

Image
I have met several local business people that either want or need a business web site beyond a brochure site. This post is aimed at those people so this category is not for techies per say but is a forum to discuss the client side of the business. Let's assume the web client needs to be able to Introduce Company and People Provide contact information and previous work bonafides Provider specific and detailed information about the products or services they provide to local clientele Provide access so that company person can manage site's information Show enough design thought that customers don't think someone's eight-year old just learned HTML So why pay a programmer (like me) upwards of $60/hour for this. This is basically a web site builder . You can buy this for around $10/month with more features and designs than you need. What skills do you need to be able to do this yourself? Able to use a computer browser Able to type/edit on keyboard Able to read and

Dina's Pet Project Summary

Image
So where am I with my Pet Project?   the domain name(several really) purchased domain names linked to the web server email entries set up new virtual development server (Thanks Wayne) VS2005 web project with a middle layer library SQL Server database for project SQL Server database for bugtracker/issue mgmt CodeSmith .NetTier with a template close to what I need basic but ugly functionality using Microsoft Membership, Roles (Profiles are home grown)