Click here to Skip to main content
15,890,438 members
Home / Discussions / Database
   

Database

 
AnswerRe: help with connecting to database server Pin
Mike Dimmick28-Feb-06 6:28
Mike Dimmick28-Feb-06 6:28 
GeneralRe: help with connecting to database server Pin
cpence2528-Feb-06 13:03
cpence2528-Feb-06 13:03 
QuestionHow to insert records into two tables using single Query Pin
Rajkamal_dfine27-Feb-06 18:53
Rajkamal_dfine27-Feb-06 18:53 
AnswerRe: How to insert records into two tables using single Query Pin
Andy Brummer27-Feb-06 19:02
sitebuilderAndy Brummer27-Feb-06 19:02 
Questionrow.Insert(x) isn't updating my table. Pin
3197527-Feb-06 10:56
3197527-Feb-06 10:56 
AnswerRe: row.Insert(x) isn't updating my table. Pin
Ritesh123427-Feb-06 19:53
Ritesh123427-Feb-06 19:53 
AnswerRe: row.Insert(x) isn't updating my table. Pin
3197515-Mar-06 10:34
3197515-Mar-06 10:34 
QuestionExecute an SQL command with return value Pin
stephanm@cae.ca27-Feb-06 8:33
stephanm@cae.ca27-Feb-06 8:33 
Hi,

I try to call a SQL function which is generated my Id, but the problem is that the return value return 0. Also to be able to execute the function, I have to remove the commandtype definition of my code.
----------------------------------------------------------------

Code where my command line is build
////////////////////////////////////
<br />
public void ExecuteStoredProcedure(string pStoredProcedureName, <br />
                                       object[] pReturnValue)<br />
    {<br />
      if(dbConnection.IsConnected())<br />
      {<br />
        bool outputValue = false;<br />
        command.Parameters.Clear();<br />
        try<br />
        {  <br />
        foreach(IDbDataParameter parameter in parameterCollection)<br />
        {<br />
          if(parameter.Direction != ParameterDirection.Input)<br />
            outputValue = true;<br />
          command.Parameters.Add(parameter);      <br />
        }<br />
        command.CommandText = dbConnection.FormatStoredProcedureCall<br />
                                                           (pStoredProcedureName, <br />
                                                            command.Parameters);<br />
<br />
        //command.CommandType = System.Data.CommandType.StoredProcedure;           <br />
	if(outputValue)<br />
	{<br />
		IDataReader reader = command.ExecuteReader();<br />
		reader.Close();         <br />
						<br />
		int count = 0;<br />
					  <br />
		foreach(IDbDataParameter parameter in command.Parameters)<br />
		{<br />
			Console.WriteLine("Parameter value:" + parameter.Value.ToString());<br />
<br />
			if(parameter.Direction != ParameterDirection.Input)<br />
			{<br />
				pReturnValue[count] = parameter.Value;<br />
				count++;<br />
			}<br />
		}  <br />
	}<br />
	else<br />
		command.ExecuteNonQuery();<br />
        }<br />
        catch(Exception e)<br />
        {<br />
          throw new DbException(ErrorMessage.INVALID_METHOD);<br />
        }       <br />
        parameterCollection.Clear();<br />
      }<br />
      else<br />
        throw new DbException(ErrorMessage.NOT_CONNECTED);<br />
    }<br />

Code when I call my function who generate my Id
///////////////////////////////////////////////
public static string NewId(ICommand pCommand, int pModuleId)<br />
{<br />
        string sqlStatement = "NewRecordId";<br />
	object[] id = new object[1];	<br />
        try<br />
        {		<br />
	  pCommand.DefineParameter("pReturnValue", <br />
	  			  DbType.String, <br />
				  null, <br />
				  ParameterDirection.ReturnValue, <br />
				  30);<br />
	  pCommand.DefineParameter("pCurrentDate", <br />
				  DbType.DateTime, <br />
				  DateTime.Now);<br />
	  pCommand.DefineParameter("pNewId", <br />
				  DbType.String, <br />
				  Guid.NewGuid().ToString());<br />
  	  pCommand.ExecuteStoredProcedure(sqlStatement, id);            <br />
	<br />
	  if (id[0].ToString().Length != 30)<br />
		throw new DatabaseLayerException("Genearated Id doesn't have 30 digits.");<br />
      }<br />
      catch(Exception e)<br />
      {<br />
	throw new DatabaseLayerException("LCMS5000", e.Message);<br />
      }<br />
			<br />
			return(pModuleId.ToString() + id[0].ToString());<br />
		}


help will be appreciated.Confused | :confused:

Stephan Martin
QuestionSQL Server Comparing Dates Pin
Murthy India27-Feb-06 2:36
Murthy India27-Feb-06 2:36 
AnswerRe: SQL Server Comparing Dates Pin
J4amieC27-Feb-06 2:48
J4amieC27-Feb-06 2:48 
GeneralRe: SQL Server Comparing Dates Pin
Paul Conrad27-Feb-06 15:33
professionalPaul Conrad27-Feb-06 15:33 
GeneralRe: SQL Server Comparing Dates Pin
Murthy India27-Feb-06 18:19
Murthy India27-Feb-06 18:19 
QuestionDynamic Database Design Pin
Ingo27-Feb-06 0:20
Ingo27-Feb-06 0:20 
AnswerRe: Dynamic Database Design Pin
darkelv27-Feb-06 4:17
darkelv27-Feb-06 4:17 
GeneralRe: Dynamic Database Design Pin
Ingo27-Feb-06 21:20
Ingo27-Feb-06 21:20 
Questionnewbie: how to get started Pin
rnvrnv26-Feb-06 23:54
rnvrnv26-Feb-06 23:54 
AnswerRe: newbie: how to get started Pin
Paul Conrad27-Feb-06 15:42
professionalPaul Conrad27-Feb-06 15:42 
QuestionSQL Profiler trace and Performance Pin
devvvy26-Feb-06 14:56
devvvy26-Feb-06 14:56 
AnswerRe: SQL Profiler trace and Performance Pin
Andy Brummer27-Feb-06 18:50
sitebuilderAndy Brummer27-Feb-06 18:50 
QuestionSQL Server log - recycling Pin
devvvy26-Feb-06 14:42
devvvy26-Feb-06 14:42 
Questionoj Pin
dev dhoundiyal26-Feb-06 5:50
dev dhoundiyal26-Feb-06 5:50 
AnswerRe: oj Pin
Colin Angus Mackay26-Feb-06 6:29
Colin Angus Mackay26-Feb-06 6:29 
GeneralRe: oj Pin
J4amieC26-Feb-06 22:38
J4amieC26-Feb-06 22:38 
QuestionUploading images to sql db Pin
foolygoofy2625-Feb-06 16:55
foolygoofy2625-Feb-06 16:55 
AnswerRe: Uploading images to sql db Pin
Luis Alonso Ramos26-Feb-06 14:17
Luis Alonso Ramos26-Feb-06 14:17 

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.