none
请教VB高手 不知道怎么修改 RRS feed

  • 问题

  • Imports System.Data.SqlClient
    Public Class Frmlogin
        Public Function runselectsql() As DataTable    '访问数据库的自定义函数
            Dim oleconn As New SqlConnection(myCnn)
            Dim strsql As String = "select * from 用户 where  姓名 ='" & Cboname.Text.Trim & "' and 密码='" & Txtpassword.Text.Trim & "'"
            Dim oleda As New SqlDataAdapter(strsql, oleconn)
            Dim oleds As New DataSet
            oleda.Fill(oleds)
            Return oleds.Tables(0) ' 返回数据集中的数据表
        End Function


        Private Sub Frmlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            SqlDataAdapter1.Fill(DataSet111) '填充数据集
        End Sub


        Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
            If checkempty(Cboname.Text) = False Then
                Cboname.Focus()
            Else
                If checkempty(Txtpassword.Text) = False Then
                    Txtpassword.Focus()
                Else
                    Dim oledt As DataTable = runselectsql() '调用自定义函数
                    If oledt.Rows.Count <> 0 Then
                        username = Cboname.Text.Trim
                        userpassword = Txtpassword.Text.Trim

                        Me.Hide()
                        Dim frmmain As New Frmmain
                        Frmmain.Show()

                    Else
                        MessageBox.Show("密码不正确,请重新输入密码", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                        Txtpassword.Text = ""
                        Txtpassword.Focus()
                    End If
                End If
            End If
        End Sub

        Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
            Me.Close()
        End Sub
    End Class

    程序第四行报错,未处理ArgueException(不支持关键字:‘data sourse’)

    2009年12月6日 2:42

答案