数据未使用c#插入数据库中,这是错误的地方. [英] data is not inserting in data base ,using c# , where is the mistake..
本文介绍了数据未使用c#插入数据库中,这是错误的地方.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它没有在我正在执行的操作中插入数据...,它显示捕获错误消息
it is not inserting the data where i am doing the mistak... , its showing catch error message
string Patient_name = NameTxtBx.Text, Export_TO = ToTxtBx0.Text, repType = RadioButtonList2.SelectedValue ;
int PatNoVal;
PatNoVal = Convert.ToInt32(PatNo.Text);
PatNoVal = int.Parse(PatNo.Text);
decimal PatID = decimal.Parse(PatID_NO.Text);
int? replay_To_type = Int16.Parse(DropDownList1.SelectedValue);
int idcount;
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Transaction";
cmd.Parameters.AddWithValue(" @Patient ", Patient_name);
cmd.Parameters.AddWithValue("@E_TO ", Export_TO);
cmd.Parameters.AddWithValue ("@R_type ",repType);
cmd.Parameters.AddWithValue("@ReportType ",replay_To_type);
cmd.Parameters.AddWithValue(" @Patient_no ",PatNoVal);
cmd.Parameters.AddWithValue(" @Patient_ID_NO ",PatID);
cmd.Parameters.Add("@idcount", SqlDbType.Decimal);
//idcount.Precision = 18;
//idcount.Scale = 0;
cmd.Parameters["@idcount"].Direction = ParameterDirection.Output;
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
TextBox1.Text = cmd.Parameters["@RETURNOUT"].Value.ToString();
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.GetType(), "IDCount", "alert('"+cmd.Parameters["@RETURNOUT"].Value.ToString()+"');", true);
}
catch
{
Message("block 3:Error", this);
}
[edit]已添加代码块-OriginalGriff [/edit]
[edit]Code block added - OriginalGriff[/edit]
推荐答案
出于相同的原因,我们无法告知您:您的代码隐藏了错误.
更改挡块:
We can''t tell for the same reason you can''t: Your code hides the error.
Change the catch block:
catch (Exception ex)
{
Message("Block 3: Error\nThe Reported fault is:\n" + ex.Message, this);
}
那样,如果错误消息没有为您提供足够的信息,则可以在异常上放置一个断点并查看详细信息.
That way, if the error message does not give you enough information, you can put a break point on the exception and view the detail.
它甚至可以编译吗?
例如,以下行:
Is it even compiling?
For instance, this line:
SqlCommand cmd = new SqlCommand;
这篇关于数据未使用c#插入数据库中,这是错误的地方.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文