如下代码运行后,显示问题出错```不支持关键字:?为什么呢?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 测试2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
//Data Source=L_RYAN-PC\SQLEXPRESS;Initial Catalog=test;Integrated Security=True
string ConnectionString = "SIMON-PC\\SQLEXPRESS\\SQLEXPRESS;Initial Catalog=Hospetal;Integrated Security=True";
using(SqlConnection conn = new SqlConnection())//创建连接对象
{
conn.ConnectionString = ConnectionString;//给连接对象的连接路径赋值

conn.Open();//运行连接对象,即是连接数据库

SqlCommand cmd = new SqlCommand();//创建命令对象

cmd.Connection = conn;//命令对象通过连接对象连接数据库发送命令

cmd.CommandText = "insert into 病人 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";//命令对象发送命令的原文本

int i = cmd.ExecuteNonQuery();//运行命令对象

MessageBox.Show("插入成功!");
}
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

}
}

侃侃无极
浏览 193回答 1
1回答

沧海一幻觉

string ConnectionString = "server=SIMON-PC\\SQLEXPRESS\\SQLEXPRESS;Initial Catalog=Hospetal;Integrated Security=True";
打开App,查看更多内容
随时随地看视频慕课网APP