public ULCommand CreateAddProductCommand(ULConnection conn, ULTransaction transaction) { var cmd = new ULCommand(ConvertToUltraLiteQuery(_sql), conn, transaction); CreateParameters(cmd); return cmd; }
private static ULCommand CreateCommand(string commandText, CommandType commandType) { ULCommand newCommand = new ULCommand(); newCommand.CommandText = commandText; newCommand.CommandType = commandType; return(newCommand); }
/// <devdoc> /// Discovery has to be done on its own connection to allow for the case of the /// connection being used being enrolled in a transaction. The ULCommandBuilder.DeriveParameters /// method creates a new ULCommand internally to communicate to the database, and it /// reuses the same connection that is passed in on the command object. If this command /// object has a connection that is enrolled in a transaction, the DeriveParameters method does not /// honor that transaction, and the call fails. To avoid this, create your own connection and /// command, and use them. /// /// You then have to clone each of the IDataParameter objects before it can be transferred to /// the original command, or another exception is thrown. /// </devdoc> private ULCommand CreateNewCommandAndConnectionForDiscovery() { ULConnection clonedConnection = (ULConnection)((ICloneable)((IDbConnection)this.command.Connection)).Clone(); clonedConnection.Open(); ULCommand newCommand = CreateCommand(this.command.CommandText, this.command.CommandType); newCommand.Connection = clonedConnection; return(newCommand); }
private void DisplayDataForQuery() { dataGridView1.DataSource = null; if (queryBuilder.MetadataProvider != null && queryBuilder.MetadataProvider.Connected) { if (queryBuilder.MetadataProvider is UniversalMetadataProvider) { if (this.DatabasePlatform == QueryBuilderDatabasePlatform.SQLAnywhereUL) { ULCommand command = (ULCommand)queryBuilder.MetadataProvider.Connection.CreateCommand(); command.CommandText = queryBuilder.SQL; // handle the query parameters if (queryBuilder.Parameters.Count > 0) { for (int i = 0; i < queryBuilder.Parameters.Count; i++) { if (!command.Parameters.Contains(queryBuilder.Parameters[i].FullName)) { ULParameter parameter = new ULParameter(); parameter.ParameterName = queryBuilder.Parameters[i].FullName; parameter.DbType = queryBuilder.Parameters[i].DataType; command.Parameters.Add(parameter); } } using (QueryParametersForm qpf = new QueryParametersForm(command)) { qpf.ShowDialog(); } } ULDataAdapter adapter = new ULDataAdapter(command); DataSet dataset = new DataSet(); try { adapter.Fill(dataset, "QueryResult"); dataGridView1.DataSource = dataset.Tables["QueryResult"]; } catch (Exception ex) { MessageBox.Show(ex.Message, "SQL query error"); } } //end sql anywhere UL } //end universal metadata provider } //end check if connected } //end method
/// <summary> /// <para>Initialize a new instance of the <see cref="Sybase9CommandWrapper"/> class with the text of a query and the command type.</para> /// </summary> /// <param name="commandText"><para>The stored procedure name or UL sting the command represents.</para></param> /// <param name="commandType"><para>One of the <see crer="CommandType"/> values.</para></param> /// <param name="parameterToken"><para>The parameter delimeter for database commands.</para></param> internal Sybase9CommandWrapper(string commandText, CommandType commandType, char parameterToken) { this.parameterToken = parameterToken; this.command = CreateCommand(commandText, commandType); }
private void SetAddCommandParameters(ULCommand cmd, Product product) { cmd.Parameters[0].Value = product.ID; cmd.Parameters[1].Value = product.ProductCode; cmd.Parameters[2].Value = product.Name; cmd.Parameters[3].Value = product.Manufacturer; cmd.Parameters[4].Value = product.Size; cmd.Parameters[5].Value = !product.Active; cmd.Parameters[6].Value = product.BarCode; }
private void CreateParameters(ULCommand cmd) { cmd.Parameters.Add(new ULParameter("id", ULDbType.Integer)); cmd.Parameters.Add(new ULParameter("code", ULDbType.VarChar, 15)); cmd.Parameters.Add(new ULParameter("name", ULDbType.VarChar, 255)); cmd.Parameters.Add(new ULParameter("mft", ULDbType.VarChar, 56)); cmd.Parameters.Add(new ULParameter("size", ULDbType.VarChar, 15)); cmd.Parameters.Add(new ULParameter("discontinued", ULDbType.Bit)); cmd.Parameters.Add(new ULParameter("barcode", ULDbType.VarChar, 56)); }
private static ULCommand CreateCommand(string commandText, CommandType commandType) { ULCommand newCommand = new ULCommand(); newCommand.CommandText = commandText; newCommand.CommandType = commandType; return newCommand; }