weixin_42934341
奶油泡啊泡
2020-05-23 10:14
采纳率: 50%
浏览 250

请问这是链接数据库失败么?但是我成功附加数据库了,请求大佬帮我解决?

图片说明
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 AddProductor : System.Web.UI.Page
{
DataAccess MarketBase = new DataAccess();
protected void Page_Load(object sender, EventArgs e)
{

    if (!IsPostBack)
    {
        SqlConnection conn = new SqlConnection(MarketBase.SqlBase);
        conn.Open();
        DataTable dt1 = new DataTable();
        dt1 = MarketBase.DisPlayList_Ds("select * from GoodType", conn);
        firstKind.DataTextField = "TypeName";
        firstKind.DataValueField = "GoodTypeID";
        firstKind.DataSource = dt1.DefaultView;
        firstKind.DataBind();
        DataTable dt = new DataTable();
        int id = int.Parse(firstKind.Value);
        dt = MarketBase.DisPlayList_Ds("select * from GoodType2 where GoodTypeID='" + id + "'", conn);
        secondKind.DataTextField = "GoodType2Name";
        secondKind.DataValueField = "GoodType2ID";
        secondKind.DataSource = dt.DefaultView;
        secondKind.DataBind();
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • caozhy
    已采纳

    SqlConnection conn = new SqlConnection(MarketBase.SqlBase);
    这个里面 MarketBase.SqlBase 是什么

    这个连接字符串里面sa密码错误,或者你的sql server没有开启混合验证。

    点赞 评论
  • qq_28199467

    检查一下连接字符串语句

    点赞 评论

相关推荐