标题:新手请教一问题用户代码未处理 System.Data.SqlClient.SqlException
取消只看楼主
meifrance
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-9-14
 问题点数:0 回复次数:2 
新手请教一问题用户代码未处理 System.Data.SqlClient.SqlException
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Expert_TxtDeal : System.Web.UI.Page
{
    private static string strConnect = System.Configuration.ConfigurationManager.AppSettings["connStr"];
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["ExpertName"] != null)
            {
                List();
            }
            else
            {
                Response.Redirect("ExpertLogin.aspx");
            }
        }  
    }
    private void List()//显示稿件细节
    {//绑定稿件数据
        string Id = Request.QueryString["ID"];
        SqlConnection sqlcon = new SqlConnection(strConnect);
        string sqlstr = "select * from Gaojian where TxtId ='" + Id + "'";
        sqlcon.Open();
        SqlCommand sqlcmd2 = new SqlCommand(sqlstr, sqlcon);
        sqlcmd2.Parameters.Add("@TxtId", SqlDbType.VarChar);
        sqlcmd2.Parameters["@TxtId"].Value = Request.QueryString["Id"].ToString();
        SqlDataReader sdr = sqlcmd2.ExecuteReader();
        if (sdr.Read())
        {
            this.LabId.Text = Convert.ToString(sdr["TxtId"]);
            this.LabClass.Text = Convert.ToString(sdr["Classname"]);
            this.LabTitle.Text = Convert.ToString(sdr["TxtTitle"]);
            this.LabAuthor.Text = Convert.ToString(sdr["AuthorName"]);
            this.LabStage.Text = "同意审评";
            this.LabShenTime.Text = DateTime.Now.ToString();
           // Session["download"] = Convert.ToString(".." + "/" + sdr["FilePath"]);
            //this.HlinkQuanWen.NavigateUrl = Session["download"].ToString();
        }
        sqlcon.Close();

    }
    protected void LbtnHand_Click(object sender, EventArgs e)
    {
        string Id = Request.QueryString["ID"];
        SqlConnection sqlcon = new SqlConnection(strConnect);
        SqlCommand sqlcmd = new SqlCommand("", sqlcon);
        sqlcon.Open();
         =
            "Update Gaojian Set ExamStage=@ExamStage,LModiDate=@LModiDate,ExamOpinion=@ExamOpinion,TitleIdea=@TitleIdea,FieldIdea=@FieldIdea,ScienceLev=@ScienceLev,TxtValue=@TxtValue,TitleCharm=@TitleCharm,EgTlLeval=@EgTlLeval,IntroReal=@IntroReal,ContLev=@ContLev ,PointLev=@PointLev,GarphLev=@GarphLev,RefBook=@RefBook ,ExamResult=@ExamResult Where TxtId='"+ Id +"'";
        sqlcmd.Parameters.Add("ExamStage", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("LModiDate", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("ExamOpinion", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("TitleIdea", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("FieldIdea", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("ScienceLev", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("TxtValue", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("TitleCharm", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("EgTlLeval", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("IntroReal", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("ContLev", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("PointLev", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("GarphLev", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("RefBook", SqlDbType.VarChar);
        sqlcmd.Parameters.Add("ExamResult", SqlDbType.VarChar);

        string yishen = "已审";
        sqlcmd.Parameters["ExamStage"].Value=yishen.ToString();
        sqlcmd.Parameters["LModiDate"].Value=DateTime.Now;
        sqlcmd.Parameters["ExamOpinion"].Value=txtOpinion.Text;
        sqlcmd.Parameters["TitleIdea"].Value=Rbtnxinyin.SelectedItem.Text.Trim();
        sqlcmd.Parameters["FieldIdea"].Value=RbtnCdu.SelectedItem.Text.Trim();
        sqlcmd.Parameters["ScienceLev"].Value=RbtnLevel.SelectedItem.Text.Trim();
        sqlcmd.Parameters["TxtValue"].Value=RbtnYIyi.SelectedItem.Text.Trim();
        sqlcmd.Parameters["TitleCharm"].Value=RbtnXiyin.SelectedItem.Text.Trim();
        sqlcmd.Parameters["EgTlLeval"].Value=RbtnZhiLiang.SelectedItem.Text.Trim();
        sqlcmd.Parameters["IntroReal"].Value=RbtnQYan.SelectedItem.Text.Trim();
        sqlcmd.Parameters["ContLev"].Value=RbtnNeiRong.SelectedItem.Text.Trim();
        sqlcmd.Parameters["PointLev"].Value=RbtnLunDian.SelectedItem.Text.Trim();
        sqlcmd.Parameters["GarphLev"].Value=RbtnTuBiao.SelectedItem.Text.Trim();
        sqlcmd.Parameters["RefBook"].Value=RbtnCanKao.SelectedItem.Text.Trim();
        sqlcmd.Parameters["ExamResult"].Value=RbtnResult.SelectedItem.Text.Trim();

        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();
        Response.Write("<script language=javascript>alert('提交成功!');location.href='DaiShenGaoJian.aspx'</script>");
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        string Id = Request.QueryString["ID"];
        SqlConnection sqlcon = new SqlConnection(strConnect);
        SqlCommand sqlcmd = new SqlCommand("", sqlcon);
        sqlcon.Open();
         =
            "Update Gaojian set ExamStage='送审' Where TxtId='" + Id + "'";
        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();
        Response.Redirect("DaiShenGaoJian.aspx");
    }
}
搜索更多相关主题的帖子: 用户 private 
2011-06-15 22:08
meifrance
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-9-14
得分:0 
sqlcmd.ExecuteNonQuery();
在此出现问题
2011-06-15 22:09
meifrance
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-9-14
得分:0 
无法从string类型的转为datetime类型的。。这个LModiDate", 这项数据库中是datetime类型的啊,难道不能转换么?
2011-06-15 22:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-342997-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.057807 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved