请问一下我在VC里面用Sqllite插入记录的问题:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请问一下我在VC里面用Sqllite插入记录的问题:相关的知识,希望对你有一定的参考价值。

请问一下我在VC里面用Sqllite的问题:
//"INSERT INTO [EC_Dict] ([WordID], [Word], [YinBiao], [JieShi]) VALUES ('m_WordNum','m_Word','m_YinBiao','m_ExPlain');",

"INSERT INTO [EC_Dict] ([WordID], [Word], [YinBiao], [JieShi]) VALUES (StrWordID,StrWord,StrYinBiao,StrJieShi);",

用上面的已经就可以,用下面的一句就不可以,其中:
strcpy(StrWordID,m_WordNum.GetBuffer(m_WordNum.GetLength()));
strcpy(StrWord,m_Word.GetBuffer(m_Word.GetLength()));
strcpy(StrYinBiao,m_YinBiao.GetBuffer(m_YinBiao.GetLength()));
strcpy(StrJieShi,m_ExPlain.GetBuffer(m_ExPlain.GetLength()));
也就是说,如果传字符串是可以的,传字符串变量就不可以了,如果要传字符串变量改怎么传?
谢谢大家的回答,现在又有新的问题:
sprintf(StrSql,"SELECT * FROM EC_Dict where %s = \'%s\';","WordID",StrWordID);
rc = sqlite3_exec(db, "BEGIN;", 0, 0, &zErrMsg);
rc = sqlite3_get_table( db , StrSql , &azResult , &nrow , &ncolumn , &zErrMsg );
无论查询是否成功rc都会返回SQLITE_OK,只是成功的时候azResult , nrow , ncolumn里可以读取正确的值
删除记录也是这样,请用过sqlite的大侠帮看看是怎么回事,谢谢,如果能解决问题,可以加分!

SQLited的insert语句如何插入变量收藏
用sprintf可以实现字符串的变换如下面程序例子:void thread(arg)
char buf[256];
char *sql2;
int data;
data=arg; sprintf(buf,"insert into\"f2store\" values(%d);",data);
sql2=buf;
sqlite3_exec(db,sql2,0,0,&zErrMsg);
大概就是这样了!哈哈
参考技术A char szSql[1024] = 0;
sprintf(szSql, "INSERT INTO [EC_Dict] ([WordID], [Word], [YinBiao], [JieShi]) VALUES (%s,%s, %s, %s,);", StrWordID,StrWord,StrYinBiao,StrJieShi);
再使用szSql即可

请问,谁知道VC中的SetTimer怎么用?

rt.能不能说的详细些.

1. SetTimer ---The SetTimer function creates a timer with the specified time-out value.
(这个函数创建一个指定时间值的定时器)
2.SetTimer原型:(摘于MSDN)
UINT_PTR SetTimer(
HWND hWnd, // handle to window(与那个窗口建立联系)
UINT_PTR nIDEvent, // timer identifier(该定时器的标志)
UINT uElapse, // time-out value(触发时间)
TIMERPROC lpTimerFunc // timer procedure(回调函数,若NULL则发WM_TIMER消息)
);
3.细讲定时器:
第一个参数:1、NULL,则第二个参数随之被忽视
2、窗口句柄,则与该窗口建立联系,会向该窗口发送消息(当第四个参数为NULL)
第二个参数:窗口的标志,如果创建了多个定时器,如果标志一样,那么系统会采用标志最高的那位。(也就是给每一个定时器取个名字,用于系统分别)
第三个参数:触发时间
第四个参数:如果NULL则向建立窗口的函数发送WM_TIMIER消息,如果指定函数,由系统自动调用该回调函数
回调函数原型:
UINT SetTimer
(
HWND hWnd,
UINT nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);
参考技术A 嗯,SetTimer 这个函数嘛
它是用来实现VC,VB中托管代码程序中的 时钟控件的的功能的
哈哈,它不像楼上说的什么,设置系统的时间

看哈,我来教你
BOOL CMy121Dlg::OnInitDialog()

......
SetTimer(0,100,NULL);
.......

我添加了这个函数在初使化的函数里
这个函数的意义是
SetTimer(
参数一:每个周期触发的事件代号,数字形,如 1 为事件一
参数二:发生这个事件的周期
参数三:每发生这个事件时,要执行的函数
)
每发生一次事件,这个函数会向窗口发送一个WM_TIMER 消息,这个消息的WPARAM 参数就是 参数一 :)
可以在消息映射里加入代码来周期执行某件事
我只是介绍了这个函数的用法,有关其它的,具体的是例,你可以加我QQ:1125591 我可以教你,反正署假无聊,不过过了署假,就没时间了,高三了,要好好读书了
参考技术B 函数名: settime
功 能: 设置系统时间
用 法: void settime(struct time *timep);
程序例:

#include <stdio.h>
#include <dos.h>

int main(void)

struct time t;

gettime(&t);
printf("The current minute is: %d\n", t.ti_min);
printf("The current hour is: %d\n", t.ti_hour);
printf("The current hundredth of a second is: %d\n", t.ti_hund);
printf("The current second is: %d\n", t.ti_sec);

/* Add one to the minutes struct element and then call settime */
t.ti_min++;
settime(&t);

return 0;
参考技术C MSDN的详细说明,看不懂去查字典
SetTimer Function

--------------------------------------------------------------------------------

The SetTimer function creates a timer with the specified time-out value.

Syntax

UINT_PTR SetTimer( HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);
Parameters

hWnd
[in] Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
nIDEvent
[in] Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored. If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored.
uElapse
[in] Specifies the time-out value, in milliseconds.
Windows NT/2000/XP: If uElapse is greater than 0x7fffffff, the timeout is set to 1.

Windows 2000/XP: If uElapse is less than 10, the timeout is set to 10.

Windows Server 2003: If uElapse is greater than 0x7fffffff, the timeout is set to 0x7fffffff.

lpTimerFunc
[in] Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter.
Return Value

If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer.

If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.

If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.

Remarks

An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.

The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.

The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct.

SetTimer can reuse timer IDs in the case where hWnd is NULL.

Example

For an example, see Creating a Timer.

Function Information

Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1

最简单的使用方法

SetTimer( hWnd, 1, 1000, NULL);

定义一个一秒的定时器(1000 就是一秒,100就是0.1秒),NULL比表示不使用函数过程,相应WM_TIMER 消息。 hWnd 为窗口的句柄,此窗体接受WM_TIMER 消息. 也就是说你的要没一秒重运行的东西放到这个消息的过程里就行了。

例如
…………
case WM_TIMER : //假如这是一个消息循环处理过程。。

MessageBox(hWnd,…………); //没秒钟出来一个提示框

break;

1 为定时器标号,用于不需要定时器时调用 KillTimer释放。

以上是关于请问一下我在VC里面用Sqllite插入记录的问题:的主要内容,如果未能解决你的问题,请参考以下文章

sqllite插入numpy数组到数据库

vc动态链接库的调用 LoadLibrary()路径问题

请问下面的图片左上方的两个按钮加中间竖线用vc++中的MFC怎么去实现?完成后,另赠100分。

怎么在outlook里面插入一个插件,用VC写的,最好是带代码,我做群发用的,有吗??好心啊!

我在VC++中写了键盘勾子程序,但当我把鼠标点到任务栏后,钩子程序就失去效果。请问啥原因呢?有啥解决

请问,谁知道VC中的SetTimer怎么用?