locked
Write to Access Database from ASP.net RRS feed

  • Question

  • User-2126623690 posted

    I am new to ASP.net but have some programming experience in VB.net with Visual Studio 2010.  What i am trying to do is load 5 fields into an access table when the user clicks a button.  We want to create a Web Application that we can put on our intranet so any user can open up and enter a Maintenance Request.  I have searched numerous different websites and found a way to get the page to load but when I click the Button, the screen flickers like something happened but I have no idea where or even if I have the connection set correctly.

    My VB.net programming experience does not include setting up a connection string.

    So with that being said, here is where I am at:

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            Dim concoaxis As SqlConnection
            Dim strInsert As String
            Dim cmdInsert As SqlCommand
            Dim dtmDate As DateTime
    
    
            dtmDate = DateTime.Now()
    
    
            concoaxis = New SqlConnection("Data Source=\\hiwts03\Files\Functional-Maintenance\01_Overall Equipment Effectiveness (OEE);Database=BMS_7.5.1.4_PreventiveMaintenance1.mdb")
            'concoaxis = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("BMS_7.5.1.4_PreventiveMaintenance1ConnectionString").ConnectionString)
            strInsert = "INSERT INTO List (RequestorName) Values (@Requestor)"
    
            cmdInsert = New SqlCommand(strInsert, concoaxis)
    
            cmdInsert.Parameters.AddWithValue("@Requestor", TextBox3.Text)
            Response.Write(TextBox3.Text)
            Try
                concoaxis.Open()
                cmdInsert.ExecuteNonQuery()
                concoaxis.Close()
                Response.Write("Updated Successfully!<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>")
            Catch
                concoaxis.Close()
            End Try
    
        End Sub


    Currently my code is only trying to Insert one field and once I figured it out I was going to add the remaining 4. 

    Any suggestions or directions?

    Thanks is Advance

    Monday, September 23, 2013 3:46 PM

Answers

All replies