如何使用Windows应用程序在SQL中存储=符号? [英] How to store = symbol in SQL using windows application?

查看:93
本文介绍了如何使用Windows应用程序在SQL中存储=符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=ASUS\SQLEXPRESS;Initial Catalog=E1;Integrated Security=True;");
            con.Open();
           // string str = "insert into '" + label4.Text + "' values('" + textBox1.Text + "','" + label2.Text + "')";
            string str = "insert into " + label4.Text + " values('" + textBox1.Text + "','" + label2.Text + "')";
            SqlCommand cmd = new SqlCommand(str,con);
            cmd.ExecuteNonQuery();
            MessageBox.Show("values inserted!");
        }





我的尝试:



i想要存储包含= symbol的数据...我使用了nvarchar(MAX)数据类型..但它不允许我存储数据。实际上数据以= symbol.please结尾帮助我..怎么做才能存储符号=



What I have tried:

i want to store data that contain = symbol...i used the nvarchar(MAX) datatype..but its not allowing me to store the data.actually the data ends with = symbol.please help me in that..what to do to store the symbol=

推荐答案

你的代码中的SQL查询看起来像



Your SQL query in the code will look like

Insert into SomeTable values ('Value1','Value2')





此查询表示有表中的2列和第一列的值是Value1,第二列的值是Value2。您应该考虑以下几点:



1.此表有2列吗?如果没有,请在查询中提供列名。

2.值是否正确?如果没有重新排序值。



最好使用列名,以便很容易理解列中的内容。



This query means that there are 2 columns in the table and value of first column is Value1 and value of second column is Value2. You should consider following points:

1. Does this table have 2 columns? If not, provide column names in the query.
2. Are the values in correct order? If not reorder values.

It is better to use column names so that it is easy to understand what goes in which column.


这篇关于如何使用Windows应用程序在SQL中存储=符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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