needanswer 0 Light Poster

Tried to make the "add" button working, it is only half working(*). I can add the new record form the textbox, but I will get the error on the datasource, datasourceID, THEN i CHANGED THE DATASOURCE TO DATASORUCEID, i GOT THE OTHER ERROR THE "dt" couldn't transfer to string, how to fix this? The other question is, the gridview in the vwd 2008 express won't properly doing the refresh? Thanks.

* HALF WORKING - i DON'T SEE THE RECORD TO ADD IN, ONLY i RERUN THIS PROGRAM.

This program;

One "add" button
Two textbox to enter the new records

&nbsp;<asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
AutoGenerateColumns="False" DataKeyNames="id" [B]DataSourceID="AccessDataSource1[/B]" 
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="779px">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\user\Desktop\honor.mdb")
        
       Dim sqlinsert As String

        sqlinsert = "INSERT INTO sysdep (sysaccount,syspw)" & _
          "VALUES(@sysaccount, @syspw)"

        Dim cmd As New OleDbCommand(sqlinsert, con1)

    cmd.Parameters.Add(New OleDbParameter("@sysaccount", TextBox1.Text))
        cmd.Parameters.Add(New OleDbParameter("@syspw", TextBox2.Text))

        Try
            con1.Open()
            cmd.ExecuteNonQuery()
        Catch ex As OleDbException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web Message")
        Catch ex As InvalidOperationException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web Message")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Web Message")
        End Try

        con1.Close()

        RefreshDGV()
    End Sub
    
Private Sub RefreshDGV()
        
Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\user\Desktop\honor.mdb")
        Dim sql As String
        sql = "SELECT * FROM sysdep"
        Dim adapter As New OleDbDataAdapter(sql, con1)
        Dim dt As New DataTable("sysdep")
        adapter.Fill(dt)
        [B]GridView1.DataSource[/B] = dt ******> ERROR MESSAGE - DataSoruce,DatasourceID, To remove 
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.