dbcmd
Adds text to the DBPROCESS command buffer.
Syntax
RETCODE dbcmd (
PDBPROCESS dbproc,
LPCSTR cmdstring );
Arguments
dbproc
Is the DBPROCESS structure that is the handle for a particular workstation or Microsoft® SQL Server™ 2000 process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
cmdstring
Is a null-terminated character string to be copied into the command buffer.
Returns
SUCCEED or FAIL.
Remarks
This function adds text to the command buffer in the DBPROCESS structure. It adds to the existing command buffer; it doesn't delete or overwrite the current contents except after the buffer has been sent to SQL Server. The user can calldbcmd repeatedly. Note that sequential calls are concatenated; the application must include any necessary blanks between the end of one line and the beginning of the next.
After a call to dbsqlexec or dbsqlsend, the first call to either dbcmd or dbfcmd automatically clears the command buffer before the new text is entered. If this situation is undesirable, set the DBNOAUTOFREE option. When DBNOAUTOFREE is set, the command buffer is cleared only by a call to dbfreebuf.
The dbfcmd function is a related function. Unlike dbcmd, dbfcmd takes additional parameters and interprets cmdstringas a format string that is passed to sprintf along with any additional parameters.
Examples
This example shows how to use dbcmd to build up a multiple-line SQL statement:
DBPROCESS *dbproc;
dbcmd(dbproc, "SELECT name FROM sysobjects");
dbcmd(dbproc, " WHERE id < 5");
dbcmd(dbproc, " AND type='S'");
Note the leading spaces in the second and third calls to dbcmd. Leading spaces are needed to properly concatenate the entire command string.
See Also
Bulk-Copy Functions
dbsetopt
dbfcmd
dbsqlexec
dbfreebuf
dbsqlsend
DB-Library Options
分享到:
相关推荐
然后,通过`connection`字符串创建`IDbConnection`对象`dbcon`,接着创建`IDbCommand`对象`dbcmd`,并用它来执行SQL命令。 执行SQL命令通常包括以下步骤: 1. 创建`IDbCommand`对象,并设置其`CommandText`属性为...
dbcmd = dbcon.CreateCommand(); dbcmd.CommandText = q; reader = dbcmd.ExecuteReader(); if(r){ return reader; } } ``` 其中,BasicQuery 函数用于执行 SQL 命令,q 参数为 SQL 命令,r 参数为是否...
dbcmd.mandtext = "Select xh, xm, mz from xsxx where mz<>'汉族'" set rs = dbcmd.execute %> 学号 姓名 民族 <td><%=rs("xh")%> <td><%=rs("xm")%> <td><%=rs("mz")%> set rs = nothing set...
cmdMap是一个HashMap,用于将SQL关键字与对应的DBCmd对象进行映射。Parser类的构造函数用于初始化Parser对象,接受一个SQL语句作为参数,并根据第一个SQL关键字确定要执行的数据库命令。 在Parser类中,我们可以...
通过在VC项目中包含DB-Library头文件和链接库,可以调用其提供的API函数,如`dbopen`、`dbcmd`、`dbexec`等来连接数据库、发送SQL命令及处理返回的结果。 3. **编程步骤** - **连接数据库**:首先,需要使用`db...
执行SQL语句通常是通过`dbcmd()`和`dbexec()`完成的,`dbcmd()`设置SQL命令,而`dbexec()`则执行该命令。处理结果集可以通过`dbresults()`和`dbfetch()`等函数来实现,这些函数允许遍历和获取查询结果中的每一行数据...
C#中DataGridView修改后直接保存到数据库... if (dbo.DBcmd(sqlcmd)) { resultshow.Text = " 编辑成功"; } else { resultshow.Text = " 编辑失败"; } } catch { MessageBox.Show("异常", "错误"); } }
`dbcmd()`用于设置要执行的SQL语句,这里是一个简单的`SELECT`语句。`dbexec()`执行SQL,如果成功或有更多结果,`dbresults()`将检查结果集。通过`dbnextrow()`遍历所有结果行,并进行相应的处理。 最后,`dbclose...
7. **存储过程调用**:通过`dbproc()`函数可以调用存储过程,通常需要先`dbcmd()`设置存储过程名称,然后传递参数。 8. **连接池**:虽然DB-Library本身不直接支持连接池,但开发者可以自行实现,以优化多个并发...
dbcmd(dbprocess,strSql); if(dbsqlexec(dbprocess) == FAIL){ printf("Query error.\n"); return false; } DBINT result_code; char infArr[MaxColumnNums][MaxColumnSize]; int retCode = 1; while (...
例如,执行SELECT查询时,可以用`dbcmd()`指定SQL语句,`dbexec()`执行后,通过`dbsqlok()`检查是否成功,再用`dbresults()`检查是否有结果集。 4. **结果集处理**:`dbnextrow()`用于获取结果集中下一行数据,`...
例如,`dbopen()`用于建立连接,`dbcmd()`用于设置SQL命令,`dbresults()`用于处理查询结果,`dbgetchar()`用于读取结果集中的数据。 2. **创建类结构**:基于这些函数,设计一个或多个C++类,将API功能映射到类的...
3. `dbcmd()`: 准备SQL命令,如SELECT、INSERT、UPDATE或DELETE语句。 4. `dbcancel()`: 取消当前执行的SQL命令,用于处理错误或中断操作。 5. `dbexec()`: 执行已准备的SQL命令。 6. `dbresults()`: 检查查询结果,...
3. **执行SQL命令**:使用`dbcmd()`函数设定要执行的SQL命令,如SELECT、INSERT、UPDATE或DELETE。然后通过`dbcursor()`开启一个新的游标,以处理查询结果。 4. **处理结果集**:使用`dbfetch()`函数遍历结果集,...
`dbcmd()` 函数用于设置 SQL 命令,而 `dbexecute()` 或 `dbSend()` 用于执行命令。 3. **游标处理**:OpenClient 提供了游标支持,允许应用程序逐行处理查询结果。通过 `dbsetlfetch()` 和 `dbgetrow()` 等函数,...
其次,在进行数据库恢复过程中,应使用dbcmd函数将存储过程的“bulk”参数设置为“true”。第三,如果dbsqlexec函数调用失败,通常是由于格式错误,因此在编写时应特别小心。最后,对于每一个批处理命令或存储过程...