报错信息: 使用者 'kye' 的登入失败。  
描述: 在执行目前 Web 要求的过程中发生未处理的例外情形。请检阅堆栈追踪以取得错误的详细信息,以及在程序代码中产生的位置。  例外详细信息: System.Data.SqlClient.SqlException: 使用者 'kye' 的登入失败。 原始程序错误:  
行 239: 
行 240:            ' execute the command 
行 241:            myConnection.Open() 
行 242:            DeleteCommand.ExecuteNonQuery() 
行 243:            myConnection.Close() 
  
  
以下是我的代码:  If Not isEditing Then             Dim keyValue As String = CStr(MyDataGrid.DataKeys(e.Item.ItemIndex))             Dim myConnection As New SqlConnection(cn.ConnectionString) 
            Dim DeleteCommand As New SqlCommand("DELETE from Icp_report where s_id='" & keyValue & "'", myConnection)             ' execute the command 
            myConnection.Open() 
            DeleteCommand.ExecuteNonQuery() 
            myConnection.Close()             ' rebind the grid 
            MyDataGrid.CurrentPageIndex = 0 
            MyDataGrid.EditItemIndex = -1 
            BindGrid() 
        End If 各位帮我看看吧,郁闷啊,  

解决方案 »

  1.   

    我確定用戶名密碼是正確的,
    如果說数据库连接的用户名和密码不对,那為什麼這一段以能運行呢,
    Public Sub OpenDatabase()
            cn.ConnectionString = "Server=192.168.203.30;Database=dgkye;Uid=sa; Pwd=as"
            cn.Open()
        End Sub       Sub BindGrid()
            Dim myConnection As SqlConnection = cn
            Dim ds As DataSet = New DataSet
            Dim adapter As SqlDataAdapter = New SqlDataAdapter("Select * from Icp_report", myConnection)
            adapter.Fill(ds, "Icp_report")
            MyDataGrid.DataSource = ds.Tables("Icp_report").DefaultView
            MyDataGrid.DataBind()
            ShowStats()    End Sub
      

  2.   

    "DELETE from Icp_report where s_id='" & keyValue & "'"
    這句話有問題呀
    應為
    "DELETE Icp_report where s_id='" & keyValue & "'"
      

  3.   

    把你的sql 语句,用 Response打出来看看是什么,在查询分析器中执行一下
      

  4.   

    你能运行的那段代码中数据库连接是:
    cn.ConnectionString = "Server=192.168.203.30;Database=dgkye;Uid=sa; Pwd=as"
    用户名是sa,而你不能运行的那段代码中提示的用户名是:kye