Example #1
0
		public override void ExecProc (string commandText, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
		{
			Parameters = parameters;
			ExecuteQuery (BuildProcedureCall (commandText), timeout, wantResults);
		}
Example #2
0
		public override string Prepare (string sql, TdsMetaParameterCollection parameters)
		{
			Parameters = parameters;

			Random rand = new Random ();
			StringBuilder idBuilder = new StringBuilder ();
			for (int i = 0; i < 25; i += 1)
				idBuilder.Append ((char) (rand.Next (26) + 65));
			string id = idBuilder.ToString ();

			//StringBuilder declare = new StringBuilder ();

		
			sql = String.Format ("create proc {0} as\n{1}", id, sql);
			short len = (short) ((id.Length) + sql.Length + 5);

			Comm.StartPacket (TdsPacketType.Normal);
			Comm.Append ((byte) TdsPacketSubType.Dynamic);
			Comm.Append (len);
			Comm.Append ((byte) 0x1); // PREPARE
			Comm.Append ((byte) 0x0); // UNUSED
			Comm.Append ((byte) id.Length);
			Comm.Append (id);
			Comm.Append ((short) sql.Length);
			Comm.Append (sql);

			Comm.SendPacket ();
			MoreResults = true;
			SkipToEnd ();

			return id;
		}
Example #3
0
		public override void ExecPrepared (string id, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
		{
			Parameters = parameters;
			bool hasParameters = (Parameters != null && Parameters.Count > 0);

			Comm.StartPacket (TdsPacketType.Normal);

			Comm.Append ((byte) TdsPacketSubType.Dynamic);
			Comm.Append ((short) (id.Length + 5));
			Comm.Append ((byte) 0x02);                  // TDS_DYN_EXEC
			Comm.Append ((byte) (hasParameters ? 0x01 : 0x00));
			Comm.Append ((byte) id.Length);
			Comm.Append (id);
			Comm.Append ((short) 0);

			if (hasParameters) {
				SendParamFormat ();
				SendParams ();
			}

			MoreResults = true;
			Comm.SendPacket ();
			CheckForData (timeout);
			if (!wantResults)
				SkipToEnd ();
		}
Example #4
0
		public override void Execute (string sql, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
		{
			Parameters = parameters;
			string ex = BuildExec (sql);
			ExecuteQuery (ex, timeout, wantResults);
		}
		internal SybaseParameterCollection (SybaseCommand command)
		{
			this.command = command;
			metaParameters = new TdsMetaParameterCollection ();
		}
		internal SqlParameterCollection (SqlCommand command)
		{
			this.command = command;
			metaParameters = new TdsMetaParameterCollection ();
		}
Example #7
0
		public override void ExecPrepared (string commandText, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
		{
			Parameters = parameters;
			// We are connected to a Sql 7.0 server
			if (TdsVersion < TdsVersion.tds80 || 
			    Parameters == null || Parameters.Count < 1) {
				base.ExecPrepared (commandText, parameters, timeout, wantResults);
				return;
			}
			TdsMetaParameterCollection parms = new TdsMetaParameterCollection ();
			parms.Add (new TdsMetaParameter ("@Handle", "int", Int32.Parse (commandText)));
			foreach (TdsMetaParameter parm in Parameters)
				parms.Add (parm);
			
			ExecRPC ("sp_execute", parms, timeout, wantResults);			
		}
Example #8
0
		public override void Execute (string commandText, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
		{
			// We are connected to a Sql 7.0 server
			if (TdsVersion < TdsVersion.tds80) {
				base.Execute (commandText, parameters, timeout, wantResults);
				return;
			}

			Parameters = parameters;
			string sql = commandText;

			if (Parameters != null && Parameters.Count > 0) {
				ExecRPC (TdsRpcProcId.ExecuteSql, commandText, parameters, timeout, wantResults);
			} else {
				if (wantResults)
					sql = BuildExec (commandText);
				ExecuteQuery (sql, timeout, wantResults);
			}
		}
		internal TdsParameterCollection (TdsCommand command)
		{
			this.command = command;
			metaParameters = new TdsMetaParameterCollection ();
		}