在线求助

问题描述

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.IO;namespaceyonghudenglu{publicpartialclassfrmEdit:Form{publicfrmEdit(){InitializeComponent();}privatestringstrConn=ConfigurationManager.ConnectionStrings["yonghudenglu.Properties.Settings.TongXunGuanLiConnectionString"].ToString();publicstringtxtFilePath="";privateintgroupCount=0;privatestringstrUserName="";privateintcontentCount=0;publicbyte[]picData;privatevoidbtnCancel_Click(objectsender,EventArgse){DialogResult=DialogResult.Cancel;}privateintID;publicfrmEdit(intid){InitializeComponent();ID=id;}privatevoidpic_Click(objectsender,EventArgse){if(dlg.ShowDialog()==DialogResult.OK){pic.Image=Image.FromFile(dlg.FileName);txtFilePath=dlg.FileName;}}privatevoidbtnOK_Click(objectsender,EventArgse){stringname;if(txtName.Text==""){MessageBox.Show("联系人姓名不能为空!","添加失败",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}else{name=txtName.Text;}stringgroup;if(cmbGroup.Text.Trim()==""){group="未分组";}else{group=cmbGroup.Text.Trim();}stringphone=txtPhone.Text.Trim();stringcompany=txtCompany.Text.Trim();stringemail=txtEmail.Text.Trim();byte[]b=null;if(txtFilePath!=""){try{FileStreamfs=newFileStream(txtFilePath,FileMode.Open,FileAccess.Read);intlen=Convert.ToInt32(fs.Length);b=newbyte[len];fs.Read(b,0,len);fs.Close();}catch{b=null;}}else{b=picData;}try{SqlConnectionconn=newSqlConnection(strConn);conn.Open();SqlCommandcmd_update=newSqlCommand();cmd_update.Connection=conn;cmd_update.CommandText="updateLianXiRensetZuBie=@ZuBie,XingMing=@XingMing,GongZuoDanWei=@GongZuoDanWei,LianXiDianHua=@LianXiDianHua,DianZiYouXiang=@DianZiYouXiang,ZhaoPian=@ZhaoPian";cmd_update.CommandText+="whereBianHao=@BianHao";cmd_update.Parameters.Add("@BianHao",SqlDbType.Int);cmd_update.Parameters.Add("@ZuBie",SqlDbType.VarChar,50);cmd_update.Parameters.Add("@XingMing",SqlDbType.VarChar,50);cmd_update.Parameters.Add("@GongZuoDanWei",SqlDbType.VarChar,500);cmd_update.Parameters.Add("@LianXiDianHua",SqlDbType.VarChar,200);cmd_update.Parameters.Add("@DianZiYouXiang",SqlDbType.VarChar,200);cmd_update.Parameters.Add("@照片",SqlDbType.Image);cmd_update.Parameters["@BianHao"].Value=ID;cmd_update.Parameters["@ZuBie"].Value=group;cmd_update.Parameters["@XingMing"].Value=name;cmd_update.Parameters["@GongZuoDanWei"].Value=company;cmd_update.Parameters["@LianXiDianHua"].Value=phone;cmd_update.Parameters["@DianZiYouXiang"].Value=email;if(txtFilePath==""&&picData==null){cmd_update.Parameters["@ZhaoPian"].Value=DBNull.Value;}else{cmd_update.Parameters["@ZhaoPian"].Value=b;}cmd_update.ExecuteNonQuery();conn.Close();DialogResult=DialogResult.OK;}catch(Exceptionee){MessageBox.Show(ee.Message,"添加失败",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}}protectedvoidLoadGroup(){try{cmbGroup.Items.Clear();SqlConnectionconn=newSqlConnection(strConn);SqlCommandcmd=newSqlCommand();cmd.Connection=conn;cmd.CommandText="selectdistinctZuBiefromLianXiRen";conn.Open();SqlDataReadersdr=cmd.ExecuteReader();while(sdr.Read()){cmbGroup.Items.Add(sdr[0].ToString());}sdr.Close();conn.Close();if(groupCount>0&&cmbGroup.Items.Count==groupCount){cmbGroup.DropDownStyle=ComboBoxStyle.DropDownList;}else{cmbGroup.DropDownStyle=ComboBoxStyle.DropDown;}}catch{}}privatevoidfrmEdit_Load(objectsender,EventArgse){strUserName=((frmMain)(this.Owner)).tsslUserName.Text;LoadGroup();SqlConnectionconn=newSqlConnection(strConn);SqlCommandcmd=newSqlCommand();cmd.Connection=conn;cmd.CommandText="select*fromLianXiRenwhereBianHao="+ID.ToString();SqlDataAdaptersda=newSqlDataAdapter(cmd);DataSetds=newDataSet();sda.Fill(ds);if(ds.Tables[0].Rows.Count==1){txtName.Text=ds.Tables[0].Rows[0]["XingMing"].ToString();cmbGroup.Text=ds.Tables[0].Rows[0]["ZuBie"].ToString();txtPhone.Text=ds.Tables[0].Rows[0]["LianXiDianHua"].ToString();txtCompany.Text=ds.Tables[0].Rows[0]["GongZuoDanWei"].ToString();txtEmail.Text=ds.Tables[0].Rows[0]["DianZiYouXiang"].ToString();if(ds.Tables[0].Rows[0]["ZhaoPian"]==DBNull.Value){pic.Image=yonghudenglu.Properties.Resources.png_0010;}else{byte[]b=(byte[])(ds.Tables[0].Rows[0]["ZhaoPian"]);pic.Image=Image.FromStream(newMemoryStream(b));picData=b;}}cmd.CommandText="select*fromYongHuwhereYongHuMing='"+strUserName+"'";conn.Open();SqlDataReadersdr=cmd.ExecuteReader();if(sdr.Read()){groupCount=Convert.ToInt32(sdr["ZuBieSLZDZ"]);contentCount=Convert.ToInt32(sdr["LianXiRenSLZDZ"]);}sdr.Close();}}}报错,必须声明标量变量"@ZhaoPianwhere"

解决方案

解决方案二:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.IO;namespaceyonghudenglu{publicpartialclassfrmEdit:Form{publicfrmEdit(){InitializeComponent();}privatestringstrConn=ConfigurationManager.ConnectionStrings["yonghudenglu.Properties.Settings.TongXunGuanLiConnectionString"].ToString();publicstringtxtFilePath="";privateintgroupCount=0;privatestringstrUserName="";privateintcontentCount=0;publicbyte[]picData;privatevoidbtnCancel_Click(objectsender,EventArgse){DialogResult=DialogResult.Cancel;}privateintID;publicfrmEdit(intid){InitializeComponent();ID=id;}privatevoidpic_Click(objectsender,EventArgse){if(dlg.ShowDialog()==DialogResult.OK){pic.Image=Image.FromFile(dlg.FileName);txtFilePath=dlg.FileName;}}privatevoidbtnOK_Click(objectsender,EventArgse){stringname;if(txtName.Text==""){MessageBox.Show("联系人姓名不能为空!","添加失败",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}else{name=txtName.Text;}stringgroup;if(cmbGroup.Text.Trim()==""){group="未分组";}else{group=cmbGroup.Text.Trim();}stringphone=txtPhone.Text.Trim();stringcompany=txtCompany.Text.Trim();stringemail=txtEmail.Text.Trim();byte[]b=null;if(txtFilePath!=""){try{FileStreamfs=newFileStream(txtFilePath,FileMode.Open,FileAccess.Read);intlen=Convert.ToInt32(fs.Length);b=newbyte[len];fs.Read(b,0,len);fs.Close();}catch{b=null;}}else{b=picData;}try{SqlConnectionconn=newSqlConnection(strConn);conn.Open();SqlCommandcmd_update=newSqlCommand();cmd_update.Connection=conn;cmd_update.CommandText="updateLianXiRensetZuBie=@ZuBie,XingMing=@XingMing,GongZuoDanWei=@GongZuoDanWei,LianXiDianHua=@LianXiDianHua,DianZiYouXiang=@DianZiYouXiang,ZhaoPian=@ZhaoPian";cmd_update.CommandText+="whereBianHao=@BianHao";cmd_update.Parameters.Add("@BianHao",SqlDbType.Int);cmd_update.Parameters.Add("@ZuBie",SqlDbType.VarChar,50);cmd_update.Parameters.Add("@XingMing",SqlDbType.VarChar,50);cmd_update.Parameters.Add("@GongZuoDanWei",SqlDbType.VarChar,500);cmd_update.Parameters.Add("@LianXiDianHua",SqlDbType.VarChar,200);cmd_update.Parameters.Add("@DianZiYouXiang",SqlDbType.VarChar,200);cmd_update.Parameters.Add("@ZhaoPian",SqlDbType.Image);cmd_update.Parameters["@BianHao"].Value=ID;cmd_update.Parameters["@ZuBie"].Value=group;cmd_update.Parameters["@XingMing"].Value=name;cmd_update.Parameters["@GongZuoDanWei"].Value=company;cmd_update.Parameters["@LianXiDianHua"].Value=phone;cmd_update.Parameters["@DianZiYouXiang"].Value=email;if(txtFilePath==""&&picData==null){cmd_update.Parameters["@ZhaoPian"].Value=DBNull.Value;}else{cmd_update.Parameters["@ZhaoPian"].Value=b;}cmd_update.ExecuteNonQuery();conn.Close();DialogResult=DialogResult.OK;}catch(Exceptionee){MessageBox.Show(ee.Message,"添加失败",MessageBoxButtons.OK,MessageBoxIcon.Error);return;}}protectedvoidLoadGroup(){try{cmbGroup.Items.Clear();SqlConnectionconn=newSqlConnection(strConn);SqlCommandcmd=newSqlCommand();cmd.Connection=conn;cmd.CommandText="selectdistinctZuBiefromLianXiRen";conn.Open();SqlDataReadersdr=cmd.ExecuteReader();while(sdr.Read()){cmbGroup.Items.Add(sdr[0].ToString());}sdr.Close();conn.Close();if(groupCount>0&&cmbGroup.Items.Count==groupCount){cmbGroup.DropDownStyle=ComboBoxStyle.DropDownList;}else{cmbGroup.DropDownStyle=ComboBoxStyle.DropDown;}}catch{}}privatevoidfrmEdit_Load(objectsender,EventArgse){strUserName=((frmMain)(this.Owner)).tsslUserName.Text;LoadGroup();SqlConnectionconn=newSqlConnection(strConn);SqlCommandcmd=newSqlCommand();cmd.Connection=conn;cmd.CommandText="select*fromLianXiRenwhereBianHao="+ID.ToString();SqlDataAdaptersda=newSqlDataAdapter(cmd);DataSetds=newDataSet();sda.Fill(ds);if(ds.Tables[0].Rows.Count==1){txtName.Text=ds.Tables[0].Rows[0]["XingMing"].ToString();cmbGroup.Text=ds.Tables[0].Rows[0]["ZuBie"].ToString();txtPhone.Text=ds.Tables[0].Rows[0]["LianXiDianHua"].ToString();txtCompany.Text=ds.Tables[0].Rows[0]["GongZuoDanWei"].ToString();txtEmail.Text=ds.Tables[0].Rows[0]["DianZiYouXiang"].ToString();if(ds.Tables[0].Rows[0]["ZhaoPian"]==DBNull.Value){pic.Image=yonghudenglu.Properties.Resources.png_0010;}else{byte[]b=(byte[])(ds.Tables[0].Rows[0]["ZhaoPian"]);pic.Image=Image.FromStream(newMemoryStream(b));picData=b;}}cmd.CommandText="select*fromYongHuwhereYongHuMing='"+strUserName+"'";conn.Open();SqlDataReadersdr=cmd.ExecuteReader();if(sdr.Read()){groupCount=Convert.ToInt32(sdr["ZuBieSLZDZ"]);contentCount=Convert.ToInt32(sdr["LianXiRenSLZDZ"]);}sdr.Close();}}}这是源代码!
解决方案三:
建议你的标题就能直接表达你的问题大概方向和意思
解决方案四:
这段代码里并没有用到@ZhaoPianwhere啊,是别的地方的问题吧
解决方案五:
数据库很冤枉的说:update语句。where之前请放一个空格。谢谢

时间: 2024-07-30 14:16:57

在线求助的相关文章

24色位图,字母图片验证码识别,基于MFC对话框的程序,在线求助,高手帮帮忙

问题描述 24色位图,字母图片验证码识别,基于MFC对话框的程序,在线求助,高手帮帮忙 24色位图(如下图)字母图片验证码识别,基于MFC对话框的程序,在线求助,高手帮帮忙

新人c++无奖问答,在线求助

问题描述 新人c++无奖问答,在线求助 编写一个自定义函数:int f( int M, int N) ,函数f的功能是:对给定的正整数M和N,找出满足方程"5x+6y=M"的正整数解中x和y都是偶数的解.要求:若M和N不都是正整数,则结束函数并返回-1:只有M和N都是正整数时,且x,y∈[1,N], 才继续求解操作,并用二重循环进行求解:(1)在函数中输出满足条件的正整数解x和y,(2)使函数值返回满足条件的正整数解的组数. #include < iostream> usi

java如何实现监控视频的数据流获取,以及摄像头的远程控制?在线求助。在此先谢过查看的人

问题描述 java如何实现监控视频的数据流获取,以及摄像头的远程控制?在线求助.在此先谢过查看的人 需求描述:我们公司做工程项目,要在自己的软件上呈现及时视频监控信息.我现在最大的问题就是想知道怎么取到指定摄像头上边的数据?摄像头厂家提供sdk工具包,都是.dll,不会用.我现在想在web页面上实现监控数据的查看?求前辈.师兄指点. 解决方案 http://download.csdn.net/detail/deartern/4913564http://www.pudn.com/downloads

opengl-关于OpenGL,在线求助

问题描述 关于OpenGL,在线求助 OpenGL中添加纹理映射或者混合后再添加光照就变成灰色而且没有光照效果了,不添加混合或纹理映射就没问题,这是怎么回事.还有纹理映射还会影响颜色,比如我在以前的纹理映射的代码基础上加反走样的时候即使吧纹理映射关了,用glDisable,图形颜色也不能显示,时候一片灰色,只有把开启纹理映射的代码全部删掉才没问题.在线求助 解决方案 http://blog.csdn.net/wangkuifeng0118/article/details/7428406 解决方案

在线求助,输入一个二叉树,如何从叶子节点向上逐层打印

问题描述 在线求助,输入一个二叉树,如何从叶子节点向上逐层打印二叉树的形式如下:ABCDEFG程序打印出,DEFGBCA用java如何实现,请高手指点一下,谢谢! 解决方案 解决方案二:先层次遍历,压入到堆栈或者向量什么的都可以...解决方案三:楼上的有没有代码示例呀?解决方案四:importjava.util.ArrayList;importjava.util.List;publicclassTest{publicstaticvoidmain(String[]args){//组装一颗树Node

c++ cfindfile-关于CFindFile FindNextFile方法。急!!!在线求助

问题描述 关于CFindFile FindNextFile方法.急!!!在线求助 BOOL CZip::RestoreFileName(CString sDirectory) { CFileFind ff; BOOL bFound = ff.FindFile(sDirectory + _T("\*.*")); TCHAR newName[260]; CString sNoteDirectory = sDirectory; sNoteDirectory += _T("\note

电脑问题-在线求助,坐等电脑大神解答。

问题描述 在线求助,坐等电脑大神解答. 为什么电脑突然打不开计算机,垃圾箱,文件夹之类的,但是游戏和网站可以打开,任务栏有显示文件,窗口打不开. 解决方案 我的电脑被偷了怎样找到

关于清理数据库冗余的上传文件在线求助!

问题描述 <!--#includefile="system.asp"--><%SubDelSpilthFile(Table,tField,FilePath)'***********************************************'过程名:DelSpilthFile'作用:删除数据库里冗余的上传文'参数:Table:数据'tField:图片字段'FilePath:图片相对文'作者:精灵QQ:3190576'随意传播转载,请保持文件完整'优化:流香

Cannot inherit from final class!在线求助,亲,不要给我翻译什么的。是官方的包出现这个问题,看描述

问题描述 这个项目是有五个工程的(能够跑起来),需要把里面一个公有类库的工程的一个平台服务器模块分离出来,成为一个单独的工程,同时与之前的五个项目建立依赖关系,并能跑起来.结果出了这档问题.我检查并修改过编译器,也升级过common-logging.jar的版本,修改过*.Properties文件,还比对过之前可以正常运行的工程,工程的Problem也都解决了,没有Problem了,网上找也找了.总之,暂时没辙了...我自己认为有两个可能性.一是某些jar包版本过低(但是为什么在原先的*.cla

在线求助!~~~~~~~~

问题描述 本人在数据库中储存了图片路径,然后通货datalist从数据库中绑订数据并且成功显示出来.现在我想通过点击任何其中的一幅图片链接到另外个页面,在那张页面调用数据库中的信息显示出产品的详情,要求那些信息是从数据库中取出来动态显示.菜鸟在线等待高手援助,谢谢. 解决方案 解决方案二:随便找一本asp.net基础教程的书中都会写如何使用DataList的用法的解决方案三:小气+不结贴.所以没有人愿意回答你.