Click here to Skip to main content
16,011,868 members
Home / Discussions / Database
   

Database

 
AnswerRe: Alter Table Add Index Pin
Elina Blank10-May-07 4:24
sitebuilderElina Blank10-May-07 4:24 
GeneralRe: Alter Table Add Index Pin
Shahzad.Aslam10-May-07 4:28
Shahzad.Aslam10-May-07 4:28 
GeneralUsing a timestamp (or something similar) Pin
Psycho-*Coder*-Extreme10-May-07 1:41
Psycho-*Coder*-Extreme10-May-07 1:41 
GeneralRe: Using a timestamp (or something similar) Pin
Tristan Rhodes10-May-07 12:57
Tristan Rhodes10-May-07 12:57 
Questioninsert record and get it's ID Pin
blackjack21509-May-07 23:45
blackjack21509-May-07 23:45 
AnswerRe: insert record and get it's ID Pin
Colin Angus Mackay10-May-07 0:09
Colin Angus Mackay10-May-07 0:09 
GeneralRe: insert record and get it's ID Pin
blackjack215010-May-07 0:27
blackjack215010-May-07 0:27 
GeneralRe: insert record and get it's ID Pin
Colin Angus Mackay10-May-07 0:37
Colin Angus Mackay10-May-07 0:37 
blackjack2150 wrote:
It can be either Access, MySql or SQL Server. The only thing that changes to select the database engine is the connection string. Therefor I don't want to do any programming at the database side(like stored procedures).


Since SQL is implemented slightly differently on each database you'll need to do more than just change the connection string. And you are already doing "programming at the database side" by just sending a SQL command through.

The way you are using now actually implies a gaping security hole as parameters are implemented differently in each langage. If you inject values in to SQL you are opening yourself up for a SQL Injection Attack. You should read SQL Injection Attacks and Tips on How to Prevent Them[^]

If you design your DAL (Data Abstraction Layer) well you can take advantage of the Strategy pattern and have one common interface to your application, but the actual concrete class will know exactly how to communicate most efficiently with the chosen database. This is the design you should be aiming for for the type of application you've described.

blackjack2150 wrote:
The trivial solution is to do insert and after select the max value of the id, hoping that nothing was inserted in between the two operations.


Well, that is risky. The other thing is to SELECT the most recent row with all the information you just inserted.

SELECT Id, Column1, Column2, Column3, Etc
FROM MyTable
WHERE Column1 = @column1
AND Column2 = @Column2
AND Column3 = @Column3
ORDER BY Id DESC


But, as you can see, it requires parameters, which are, as I've mention, defined differently in each implementation of SQL.


Upcoming events:
* Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services...

Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton


My website

AnswerRe: insert record and get it's ID Pin
Andrew Torrance10-May-07 0:14
Andrew Torrance10-May-07 0:14 
AnswerRe: insert record and get it's ID Pin
conwamt10-May-07 8:11
conwamt10-May-07 8:11 
GeneralRe: insert record and get it's ID Pin
Richard Blythe10-May-07 9:45
Richard Blythe10-May-07 9:45 
GeneralRe: insert record and get it's ID Pin
meeram39510-May-07 21:30
meeram39510-May-07 21:30 
GeneralRe: insert record and get it's ID Pin
Pete O'Hanlon10-May-07 22:57
mvePete O'Hanlon10-May-07 22:57 
AnswerRe: insert record and get it's ID Pin
Richard Blythe10-May-07 16:28
Richard Blythe10-May-07 16:28 
Questionindependent table ? Pin
Mr.Kode9-May-07 20:50
Mr.Kode9-May-07 20:50 
AnswerRe: independent table ? Pin
Vimalsoft(Pty) Ltd9-May-07 22:02
professionalVimalsoft(Pty) Ltd9-May-07 22:02 
QuestionHow do i Restore updated Column in SQL Pin
Vimalsoft(Pty) Ltd9-May-07 20:13
professionalVimalsoft(Pty) Ltd9-May-07 20:13 
AnswerRe: How do i Restore updated Column in SQL Pin
gauthee16-May-07 2:12
gauthee16-May-07 2:12 
QuestionPlease Help Me Pin
Mkanchha9-May-07 20:04
Mkanchha9-May-07 20:04 
AnswerRe: Please Help Me Pin
Christian Graus9-May-07 20:09
protectorChristian Graus9-May-07 20:09 
AnswerRe: Please Help Me Pin
Arun.Immanuel9-May-07 22:26
Arun.Immanuel9-May-07 22:26 
AnswerRe: Please Help Me Pin
Arun.Immanuel9-May-07 22:28
Arun.Immanuel9-May-07 22:28 
GeneralRe: Please Help Me Pin
Mkanchha10-May-07 0:20
Mkanchha10-May-07 0:20 
GeneralRe: Please Help Me Pin
Arun.Immanuel10-May-07 1:44
Arun.Immanuel10-May-07 1:44 
GeneralRe: Please Help Me Pin
Mkanchha10-May-07 1:57
Mkanchha10-May-07 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.