Click here to Skip to main content
15,914,594 members
Home / Discussions / Database
   

Database

 
GeneralRe: What is Buffer Pool in SqlServer? Pin
Blue_Boy21-Jul-11 2:44
Blue_Boy21-Jul-11 2:44 
AnswerRe: What is Buffer Pool in SqlServer? Pin
PIEBALDconsult21-Jul-11 2:45
mvePIEBALDconsult21-Jul-11 2:45 
QuestionSSRS 2005 Sub report issue (newbie) Pin
Paul E Davies19-Jul-11 1:07
Paul E Davies19-Jul-11 1:07 
AnswerRe: SSRS 2005 Sub report issue (newbie) Pin
Paul E Davies21-Jul-11 0:27
Paul E Davies21-Jul-11 0:27 
QuestionSQL Syntax Issue Pin
Frank Lepkowski18-Jul-11 3:04
Frank Lepkowski18-Jul-11 3:04 
AnswerRe: SQL Syntax Issue Pin
Tim Carmichael18-Jul-11 3:13
Tim Carmichael18-Jul-11 3:13 
AnswerRe: SQL Syntax Issue Pin
AnnieMacD18-Jul-11 3:38
AnnieMacD18-Jul-11 3:38 
QuestionDynamic Query Question Pin
Kevin Marois14-Jul-11 19:01
professionalKevin Marois14-Jul-11 19:01 
AnswerRe: Dynamic Query Question Pin
Blue_Boy14-Jul-11 20:54
Blue_Boy14-Jul-11 20:54 
GeneralRe: Dynamic Query Question Pin
Kevin Marois15-Jul-11 5:34
professionalKevin Marois15-Jul-11 5:34 
GeneralRe: Dynamic Query Question Pin
smcnulty200015-Jul-11 22:31
smcnulty200015-Jul-11 22:31 
AnswerRe: Dynamic Query Question Pin
smcnulty200014-Jul-11 21:53
smcnulty200014-Jul-11 21:53 
AnswerRe: Dynamic Query Question Pin
dasblinkenlight15-Jul-11 17:00
dasblinkenlight15-Jul-11 17:00 
AnswerRe: Dynamic Query Question Pin
PIEBALDconsult16-Jul-11 4:27
mvePIEBALDconsult16-Jul-11 4:27 
JokeRe: Dynamic Query Question Pin
Mycroft Holmes16-Jul-11 13:06
professionalMycroft Holmes16-Jul-11 13:06 
GeneralRe: Dynamic Query Question Pin
S Douglas11-Aug-11 9:48
professionalS Douglas11-Aug-11 9:48 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult11-Aug-11 14:49
mvePIEBALDconsult11-Aug-11 14:49 
GeneralRe: Dynamic Query Question Pin
S Douglas12-Aug-11 4:48
professionalS Douglas12-Aug-11 4:48 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult12-Aug-11 17:57
mvePIEBALDconsult12-Aug-11 17:57 
Here are a couple of simple examples. Not using my usual data access classes.

I prefer the ExecuteScalar, it was designed for this sort of thing.

System.Data.IDbConnection dbc = new System.Data.SqlClient.SqlConnection
(
    @"Server='localhost\SQLEXPRESS'; Database='Rubbish'; Trusted_Connection='True'"
) ;

System.Data.IDbCommand cmd = dbc.CreateCommand() ;

cmd.CommandText = "SELECT @voter_id=Id FROM Account WHERE " + "Name = 'Two'" ;

System.Data.IDbDataParameter prm = cmd.CreateParameter() ;

prm.ParameterName = "@voter_id" ;
prm.DbType = System.Data.DbType.Int32 ;
prm.Direction = System.Data.ParameterDirection.Output ;

cmd.Parameters.Add ( prm ) ;

dbc.Open() ;

cmd.ExecuteNonQuery() ;

int id = (int) prm.Value ;

cmd.Parameters.Clear() ;
cmd.CommandText = "SELECT Id FROM Account WHERE " + "Name = 'Three'" ;

object o = cmd.ExecuteScalar() ;

if ( o != System.DBNull.Value )
{
    id = (int) o ;
}

dbc.Close() ;

GeneralRe: Dynamic Query Question Pin
S Douglas13-Aug-11 8:20
professionalS Douglas13-Aug-11 8:20 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult13-Aug-11 9:29
mvePIEBALDconsult13-Aug-11 9:29 
GeneralRe: Dynamic Query Question Pin
S Douglas13-Aug-11 22:30
professionalS Douglas13-Aug-11 22:30 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult13-Aug-11 7:15
mvePIEBALDconsult13-Aug-11 7:15 
QuestionUPDATE Multiple tables on one filed. [modified] Pin
Member 808202113-Jul-11 11:12
Member 808202113-Jul-11 11:12 
AnswerRe: UPDATE Multiple tables on one filed. Pin
Blue_Boy13-Jul-11 23:29
Blue_Boy13-Jul-11 23:29 

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.