请问我做错了什么? [英] What I did wrong please?
本文介绍了请问我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要您的帮助,
我做错了什么?
这里 hier 是我的代码
Hi Guy i need Ur Help,
what i do wrong??
Here hier is my code
SqlConnection connection = new SqlConnection("Data Source= .\\SQLEXPRESS;"+
" Initial Catalog= zeit; integrated security = true");
SqlDataAdapter data = new SqlDataAdapter();
data.InsertCommand = new SqlCommand("insert into AbhängigkeitTabelle"+
"values("+
"Select V_ID from Netzplan where V_Name = '@VName')"+
",(select Vorgang_ID from Netzplan_2 where Abhängigkeiten ='@Ab' ))", connection);
data.InsertCommand.Parameters.Add("@VName", SqlDbType.VarChar).Value = VorgangNameTextBox.Text;
data.InsertCommand.Parameters.Add("@Ab", SqlDbType.VarChar).Value = AbhängigkeitenTextBox.Text;
connection.Open();
data.InsertCommand.ExecuteNonQuery();
MessageBox.Show(" Datei eingefügt");
connection.Close();
我认为新的SqlCommand出了点问题,但我不知道为什么.
I Think something is wrong with my new SqlCommand but i don''t know why.
推荐答案
嗨
我想
Hi
I think
Select V_ID from Netzplan where V_Name = '@VName'
select Vorgang_ID from Netzplan_2 where Abhängigkeiten ='@Ab'
上面的查询返回了不止一行.
请检查以上查询在每种情况下都不应返回多于一行.
意思是:V_Name和Abhängigkeiten列必须是唯一类型.
the above query is returning more than one row.
please check the above query should not return more than one row in every case.
means:V_Name and Abhängigkeiten columns must be unique type.
您好,
我发现了你的错误..
试试这个.
Hi there,
I caught your error..
Try this.
SqlConnection connection = new SqlConnection("Data Source= .\\SQLEXPRESS;"+
" Initial Catalog= zeit; integrated security = true");
SqlDataAdapter data = new SqlDataAdapter();
data.InsertCommand = new SqlCommand("insert into AbhängigkeitTabelle"+
" values("+
"Select V_ID from Netzplan where V_Name = '@VName')"+
",(select Vorgang_ID from Netzplan_2 where Abhängigkeiten ='@Ab' )", connection);
data.InsertCommand.Parameters.Add("@VName", SqlDbType.VarChar).Value = VorgangNameTextBox.Text;
data.InsertCommand.Parameters.Add("@Ab", SqlDbType.VarChar).Value = AbhängigkeitenTextBox.Text;
connection.Open();
data.InsertCommand.ExecuteNonQuery();
MessageBox.Show(" Datei eingefügt");
connection.Close();
这可能会对您有帮助..最好.
This may help you.. All the best.
这篇关于请问我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文