插入代码如下: string type = Request.QueryString["type"];
string Mysql, UserName, Email, Phone, Address, Title, Content;
UserName=Check.checkWebAsp(Request.Form["user"]);
Email=Check.checkWebAsp(Request.Form["email"]);
Phone=Check.checkWebAsp(Request.Form["tel"]);
Address=Check.checkWebAsp(Request.Form["address"]);
Title=Check.checkWebAsp(Request.Form["title"]);
Content=Check.checkWebAsp(Request.Form["question"]);
Content= Content.Replace("\r\n", "<br/>");
Content = Content.Replace(" ", " ");
Mysql = "Insert Into mail (username,type,time,mail,topic,";
if (Phone.Length>0 )
Mysql=Mysql+"phone,"; if (Address.Length>0 )
Mysql=Mysql+"address,"; if (Content.Length>0)
Mysql=Mysql+"text,"; Mysql=Mysql+"reflag) Values ('"+UserName+"','"+type+"','"+DateTime.Now.ToString()+"','"+Email+"','"+Title+"',";
if (Phone.Length>0 )
Mysql=Mysql+"'"+Phone.Trim()+"',"; if (Address.Length>0)
Mysql=Mysql+"'"+Address.Trim()+"',";
if (Content.Length>0)
Mysql=Mysql+"'"+Convert.ToString( Content).Trim()+"',"; Mysql = Mysql + "0)";
InsertTab(Mysql);
}text的字段是ntext,但是只能插入十来个字,其余的被截断了,为什么?
string Mysql, UserName, Email, Phone, Address, Title, Content;
UserName=Check.checkWebAsp(Request.Form["user"]);
Email=Check.checkWebAsp(Request.Form["email"]);
Phone=Check.checkWebAsp(Request.Form["tel"]);
Address=Check.checkWebAsp(Request.Form["address"]);
Title=Check.checkWebAsp(Request.Form["title"]);
Content=Check.checkWebAsp(Request.Form["question"]);
Content= Content.Replace("\r\n", "<br/>");
Content = Content.Replace(" ", " ");
Mysql = "Insert Into mail (username,type,time,mail,topic,";
if (Phone.Length>0 )
Mysql=Mysql+"phone,"; if (Address.Length>0 )
Mysql=Mysql+"address,"; if (Content.Length>0)
Mysql=Mysql+"text,"; Mysql=Mysql+"reflag) Values ('"+UserName+"','"+type+"','"+DateTime.Now.ToString()+"','"+Email+"','"+Title+"',";
if (Phone.Length>0 )
Mysql=Mysql+"'"+Phone.Trim()+"',"; if (Address.Length>0)
Mysql=Mysql+"'"+Address.Trim()+"',";
if (Content.Length>0)
Mysql=Mysql+"'"+Convert.ToString( Content).Trim()+"',"; Mysql = Mysql + "0)";
InsertTab(Mysql);
}text的字段是ntext,但是只能插入十来个字,其余的被截断了,为什么?
解决方案 »
- 设置datagridview行号的问题
- 求帮助
- 请问private System.ComponentModel.IContainer components是什么?
- web项目发布后的问题.
- C#调用VC的Dll错误:未将对象引用设置到对象的实例。错误机会不确定,随内容而定。
- 谁能帮我解释一下1000224E F3 A5 rep movs dword ptr [edi],dword ptr [esi]
- 求高手 解决
- xmlhttpRequest的在C#中用法代码(WinForm)
- FreeTextBox插入图像功能不可用?
- C#程序如何使用Fiddler获取数据?
- c# delegate
- c# 建立实体类
SqlConnection conn = new SqlConnection(ConStr);
string strSql = "insert into Hospital_Employees(EmpNum,EmpTypeNum,DeptNum,EmpName,EmpTelephone,EmpFingerTmp,EmpPassword,EmpLevel,ROLEID) values(@EmpNum,@EmpTypeNum,@DeptNum,@EmpName,@EmpTelephone,@EmpFingerTmp,@EmpPassword,@EmpLevel,@ROLEID)";
SqlCommand cmd = new SqlCommand(strSql, conn);
cmd.Parameters.Add("@EmpNum", SqlDbType.VarChar);
cmd.Parameters["@EmpNum"].Value = empnum; cmd.Parameters.Add("@EmpTypeNum", SqlDbType.SmallInt);
cmd.Parameters["@EmpTypeNum"].Value = emptypenum; cmd.Parameters.Add("@DeptNum", SqlDbType.Int);
cmd.Parameters["@DeptNum"].Value = deptnum; cmd.Parameters.Add("@EmpName", SqlDbType.VarChar);
cmd.Parameters["@EmpName"].Value = empname; cmd.Parameters.Add("@EmpTelephone", SqlDbType.VarChar);
cmd.Parameters["@EmpTelephone"].Value = empphone; cmd.Parameters.Add("@EmpFingerTmp", SqlDbType.Binary);
cmd.Parameters["@EmpFingerTmp"].Value = sTemp; cmd.Parameters.Add("@EmpPassword", SqlDbType.VarChar);
cmd.Parameters["@EmpPassword"].Value = ""; cmd.Parameters.Add("@EmpLevel", SqlDbType.Int);
cmd.Parameters["@EmpLevel"].Value = 1; cmd.Parameters.Add("@ROLEID", SqlDbType.Int);
cmd.Parameters["@ROLEID"].Value = roleid;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
//设置数据库的sql语句
string sql = string.Format("select EmpNum AS 员工编号,EmpTypeNum AS 员工类型编号,DeptNum AS 部门编号,EmpName AS 姓名,EmpTelephone AS 联系方式,ROLEID AS 角色编号 FROM Hospital_Employees");
DataTable dt = BLL.RunSqlDataTable(sql);
断点调试到这一句 把mysql里面的命令拷贝出来在数据库里运行下看看错误出在哪里?