添加用户输入数据库 [英] add user input in database

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

问题描述

我想实现这个

        Console.WriteLine("Enter Name: ");
        this.name = Console.ReadLine();
        string sql1 = "insert into items values ( " + this.name ")";
        DataAccess.ExecuteSQL(sql1);

当我尝试输入数据通过这一点,示值误差有关,unhanded例外,列名或号码不找到。

when I try to input data through this it showing error about , unhanded exception , column name or number not found.

我相信列名确定,我给它VARCHAR(50)类型。不允许这个方法?

I am sure column name is ok and I gave it varchar(50) type. Is this method not permitted?

感谢您提前。

推荐答案

第一U忘了+和第二个名字听起来也许一个varchar / nvarchar的?不是不要忘了

First u forgot a + and second name sounds like maybe a varchar/nvarchar? than dont forget the ''

Console.WriteLine("Enter Name: ");
this.name = Console.ReadLine();
string sql1 = "INSERT INTO tableName (columnName) VALUES ('" + this.name + "');"
DataAccess.ExecuteSQL(sql1);

这篇关于添加用户输入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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