system.data.sqlclient.sqlexception:列名'数量'无效
stringstrConn="workstationid=localhost;IntegratedSecurity=SSPI;database=hospitalms;";...
string strConn="workstation id=localhost;Integrated Security=SSPI;database=hospitalms;"; SqlConnection cn=new SqlConnection(strConn); cn.Open(); SqlCommand cmd=cn.CreateCommand(); string newID=this.CreateNewID("select max(编号) 最大编号 from 门诊划价"); string insertStr="insert into 门诊划价([编号], [科室], [挂号编号], [医生], [划价时间]," +"[是否收费], [划价金额], [是否发药]) values('"+newID+"','"+txt3.Text+"','"+cmb1.Text +"','"+txt4.Text+"','"+System.DateTime.Now.ToString()+"','否',CAST('"+txt5.Text+"' as money)" +",'否')"; try { cmd.CommandText=insertStr; cmd.ExecuteNonQuery(); } catch(Exception express) { MessageBox.Show(express.ToString(),"新增门诊挂号错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } foreach(DataRow aRow in newTable.Rows) { insertStr="insert into 门诊划价明细([划价编号], [药品编号], [单价], [数量], [金额]) " +"values('"+newID+"','"+aRow["编号"].ToString()+"','"+aRow["单价"].ToString()+"','" +aRow["数量"].ToString()+"','"+aRow["金额"].ToString()+"')"; try { cmd.CommandText=insertStr; // cmd.ExecuteNonQuery(); } catch(Exception express) { MessageBox.Show(express.ToString(),"新增门诊明细错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询