gpt4 book ai didi

c# - 为什么插入表不起作用?

转载 作者:行者123 更新时间:2023-12-02 17:44:35 24 4
gpt4 key购买 nike

<分区>

我想知道为什么这段代码不起作用?

SqlCommand comand = new SqlCommand();
//string myConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=try;Integrated Security=True;Pooling=False";
SqlConnection conn = new SqlConnection(@"server=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydatabase.mdf;Integrated Security=True;User Instance=True");
comand.Connection = conn;
conn.Open();

comand.CommandText = "INSERT INTO TableProduct (productID,productName) VALUES ('1','M')";

comand.ExecuteNonQuery();
conn.Close();

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com