如何将值写入数据库 [英] How do I Write Values into my Database

查看:172
本文介绍了如何将值写入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在使用Access 2003创建的Access 2003数据库时遇到了一些麻烦。


我创建了一个游戏,到目前为止我已成功将用户名写入数据库,但我不能为我的生活找出如何让它也将用户分数写入数据库(win, $ / $
每次用户玩游戏时,程序都会存储和更新这些值,我希望能够在当前用户名下将值写入数据库。


我是VB新手所以请不要认为我知道任何相当高级的东西。


到目前为止我已经得到了以下代码:

展开 | 选择 | 换行 | 行号

解决方案

提示的变量类型是什么?如果是数字,则从sql语句中删除单引号:

展开 | 选择 | Wrap | 行号


感谢您的回复:)


我刚刚再次完成了该程序。它现在成功地将提示值(数字为是:)写入字段。

然而,正在发生的是它正在创建ID = 0的新记录。

该节目首次按预期播放,然后由于没有可以制作的新记录,它将第二次挂起。


有关我如何获得的任何建议它将值写入记录,其中名称与当前正在播放的用户名相同。我认为以下行可以解决这个问题,看起来不是:)

展开 | 选择 | Wrap | 行号


我想说点什么你在上一篇文章中的第12行,但我忍住了。过滤器不会真正改变你的行的行为13.如果你想插入给定用户名的值,你必须在你的sql语句中使用WHERE子句。

展开 | 选择 | Wrap | 行号< /跨度>

Hi guys,

I''m having some trouble with linking in an Access 2003 database which i have created into Visual Basic 6.

I''ve created a game, so far i have it successfully writing the username to the database, but i cannot for the life of me figure out how to get it to also write the users scores to the database (win, lose and played).
These values are stored and updated by the program each time the user plays a game and I want to be able to write the value into the database under the current username.

I am new to VB so please dont assume i know anything quite advanced.

I have so far come up with the following code:

Expand|Select|Wrap|Line Numbers

解决方案

What variable type is Hints? If it is numeric, remove the single quotes from your sql statement:

Expand|Select|Wrap|Line Numbers


Thanks for the reply :)

I''ve just ran through the program again. It is now successfully writing the hint values, which was numerical yes :), into the field.
However what is happening is that it is creating a new record with ID = 0.
The program plays as expected first time and then it will hang the second time round since there is no new records which can be made.

Any suggestions as to how i can get it to write the value into the record where the name is the same as the username who is currently playing. I thought the following line would have fixed this issue, it appears not :)

Expand|Select|Wrap|Line Numbers


I was going to say something about your line 12 in my previous post but I refrained. The filter does nothing really to alter the behaviour of your line 13. If you want to insert values for a given username, you have to use a WHERE clause in your sql statement.

Expand|Select|Wrap|Line Numbers


这篇关于如何将值写入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆