Results 1 to 3 of 3

Thread: Connection string

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    21

    Connection string

    Hi all i am using vb 2005 with an access database 2003 vb.net website (aspx page) i am try to put contact details in to the database with six text boves and one button (Button1) to submit the informaton in run time (aspx page) when i run the page no problems then i click submit no error but it does not send the information to the dadtbase.i put the code when i double click on the button here is my code could you plz tell what i am doing wrong thanks.

    HTML Code:
    Imports System.Data
    Partial Class accessall_NewCustomer
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String
            Dim cmd As OleDb.OleDbCommand
            Dim con As New OleDb.OleDbConnection
            Try
                con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\michael\Desktop\New Web Site\Motoglass0910new222.mdb"
                con.Open()
                str = "insert into CustomerAccountDetails values(" & CInt(SurNametxt.Text) & ",'" & ForeNametxt.Text & ",'" & Addresstxt.Text & ",'" & Towntxt.Text & ",'" & Postcodetxt.Text & "','" & _PhoneNotxt.Text & "')"
    
                'string stores the command and CInt is used to convert number to string
                cmd = New OleDb.OleDbCommand(str, con)
    
            Catch
            End Try
            con.Close()
        End Sub
    End Class

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Connection string

    "when i run the page no problems" -- I don't believe that... you could have an error and not even know it... what's the point of putting your code into a Try Catch if you're going to ignore any errors that happen?
    What you have done is the .NET equivelent of On Error Resume Next.

    Code:
            Catch
            End Try
    That does nothing but ignore any errors that happen.

    At the very least, throw up a message box.
    Code:
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    21

    Re: Connection string

    thanks i am new to this i was trying to serch online sorry i don't know what i am doing but i wanted to give it a go on my on frist i will have an other go and get back to you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width