我写了如下代码来操作数据库,可是什么功能也实现不了,各位英雄豪杰帮忙看看,解决了就有分  
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        div1.Visible = False
        div2.Visible = False        btnFirst.Text = "最首页"
        btnPrev.Text = "前一页"
        btnNext.Text = "下一页"
        btnLast.Text = "最后页"
        myconn()
        BindGrid()
    End Sub
    Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
        Dim startIndex As Integer
        startIndex = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize
        MyDataGrid.CurrentPageIndex = e.NewPageIndex
        BindGrid()
        ShowStats()
    End Sub    Sub BindGrid()
        myconn()
        Dim ds As DataSet = New DataSet
        Dim adapter As SqlDataAdapter = New SqlDataAdapter("Select * from student", myConnection)
        adapter.Fill(ds, "student")
        MyDataGrid.DataSource = ds.Tables("student").DefaultView
        MyDataGrid.DataBind()
        ShowStats()    End Sub    Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)
        'used by external paging UI
        Dim arg As String = sender.CommandArgument        Select Case arg
            Case "next"
                If (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1)) Then
                    MyDataGrid.CurrentPageIndex += 1
                End If
            Case "prev"
                If (MyDataGrid.CurrentPageIndex > 0) Then
                    MyDataGrid.CurrentPageIndex -= 1
                End If
            Case "last"
                MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1)
            Case Else
                'page number
                MyDataGrid.CurrentPageIndex = System.Convert.ToInt32(arg)
        End Select
        BindGrid()
        ShowStats()
    End Sub    Sub ShowStats()
        lblCurrentIndex.Text = "第 " + (MyDataGrid.CurrentPageIndex + 1).ToString() + " 页"
        lblPageCount.Text = "总共 " + MyDataGrid.PageCount.ToString() + " 页"    End Sub
    Public myconnection As SqlConnection
    Public myconnectionstring As String
    Public conver As Integer
    Function myconn() '链接数据库
        myconnectionstring = "server=(LOCAL);database=test;user ID=sa;password=1234"
        myconnection = New SqlConnection(myconnectionstring)    End Function    Public Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click '添加记录
        div2.Visible = True
        conver = 1
    End Sub    Public Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click '删除记录
        conver = 1
        div1.Visible = True
        labinput.Text = "请输入你要删除的ID号:"
    End Sub    Public Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click '修改记录
        div2.Visible = True
        conver = 2    End Sub    Public Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button4.Click '查询记录
        myconn()
        div1.Visible = True
        labinput.Text = "请输入您要查询的ID号:"    End Sub
    Public Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click '确定修改和添加事件
        Select Case (conver)
            Case 1
                myconn()
                Dim insstr As String = "Insert Into student (ID,学号,姓名,性别,成绩)values(" + userId.Text.ToString + "," + usernum.Text.ToString + "," + name.Text + "," + sex.Text + "," + grade.Text.ToString + ")"
                condata(insstr, 1)
                condata("select * from student order by ID", 0)
            Case 2
                myconn()
                Dim upstr As String = "UPDATA student SET 学号 = " + usernum.Text.ToString + ",姓名=" + name.Text + " , 性别= " + sex.Text + " ,成绩=" + grade.Text.ToString + "where ID = " + userId.Text.ToString
                condata(upstr, 1)
                condata("select * from student order by ID", 0)
        End Select
    End Sub
    Function condata(ByVal constr As String, ByVal show As Integer) As Boolean '操作数据库事件
        Try            Dim mycommand As SqlCommand = New SqlCommand(constr, myconnection)
            myconnection.Open()
            Dim mydatareader As SqlDataReader = mycommand.ExecuteReader()
            Dim ds As DataSet = New DataSet            If show = 0 Then
                MyDataGrid.DataSource = mydatareader
                MyDataGrid.DataBind()
            End If
            myconnection.Close()
        Catch ee As Exception
            myconnection.Close()
            info.Text = "发生错误:" + ee.Message + "或者,请您确认输入的数据库名称无误:"        Finally
        End Try
    End Function    Public Sub button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button5.Click '确定删除和查询事件
        Select Case (conver)
            Case 1
                myconn()
                condata("delete * from student where ID=" + input1.Value, 1)
                condata("Select * from student Order by ID", 0)
            Case 2
                myconn()
                condata("select * from student where ID=" + input1.Value, 0)        End Select
          End Sub