Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-03-02 : 07:31:44
|
| Dan Thurman writes "Hello,I apologize as you have stated: NO ASP questionsbut I am unable to find any other resource to myspecific questions involving BOTH ASP and MSSQLdevelopment... I hope you will consider... ifyou can, perhaps you can direct me to links or placeswhere I can find such an answer?I am trying to learn how to implement ASP/MSSQL codeusing db tables with referential checks. For example,does it make sense to use SQL statements in ASP codeto update tables where records of one table must be filledbefore another table can be updated due to reference checks.The question is, can this be done strictly with SQL in ASPcode or does it require stored procedures? One problem Ihave yet to understand is, how is a FK obtained after an insertinto a table obtain in order to use it to update another table requiring it for referential checks to be satisfied usingonly SQL and ASP (and not stored procedure) code?Is there a full-blown example with ASP and Northwind (MSSQL, not Access) available that explains my question by example?Thanks!Dan" |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-03-02 : 09:04:51
|
| The question is, can this be done strictly with SQL in ASPcode or does it require stored procedures?A. You should use stored procedures for everything. Never write directly to a database from inline code. This is a security and maintenance best practice.One problem I have yet to understand is, how is a FK obtained after an insert into a table obtain in order to use it to update another table requiring it for referential checks to be satisfied usingonly SQL and ASP (and not stored procedure) code?A. DECLARE @identity_field INT INSERT table(col1,col2) values(1,2) SELECT @identity_field = SCOPE_IDENTITY() Doing this will give you the identity you just inserted.Is there a full-blown example with ASP and Northwind (MSSQL, not Access) available that explains my question by example?A. I'm not aware of any examples using Northwind. I believe ASP.NET has some good examples of code and stored procedure/database integration with their starter kits.The best thing to do is get a good SQL Server book and a good SQL Server development book. Learn how things are really working, just like you would do to learn ASP.NET. Karen Delaney has some really good books. There is a list of resources here also: http://www.sqlteam.com/store.aspMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|
|
|