Hi,

I get the error:

Format of the initialization string does not conform to specification at Index 33. I was hoping if someone could help me on this situation. The code is listed below.

'code
Imports System.Web.Mail
Imports System.Data
Imports System.Data.OleDb



'end code
Partial Class _Default
    Inherits System.Web.UI.Page
    'set the variables needed
    Dim SqlConnectionString As String
    Dim SqlConnectionStatus As String = "Closed"
    Dim Sqlconnection As New OleDbConnection
    Dim Sqlcommand As New OleDbCommand(sqlinsert, Sqlconnection)
    Dim SqlData As OleDbDataReader
    Dim sqlinsert As String

    'Function used to open the Database
    Function sqlDBconnection() As Object
        'creating the connection string
        SqlConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source='~\FDXDB3.mdb;User ID=Admin;Password=;"

        'set the connection string into the SQL connection
        Sqlconnection.ConnectionString = SqlConnectionString
        'open the connection
        Sqlconnection.Open()
        'Check to see if it was successful
        If Sqlconnection.State = ConnectionState.Open Then
            'Set the connection status to open
            SqlConnectionStatus = "Open"
        End If
        'Return the connection status
        Return SqlConnectionStatus
    End Function

    'Function used to close the database
    Function SqlDBConnectionClose() As Object
        'close the connection
        Sqlconnection.Close()

        'check to see if the connection is closed or open
        If Sqlconnection.State = ConnectionState.Open Then
            

            'Keep the connection as Open
            SqlConnectionStatus = "Open"
        Else
            'Set the Connection Status as Closed
            SqlConnectionStatus = "Closed"
        End If
        Return SqlConnectionStatus
    End Function



    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        'This opens the Database so you can enter information into ti
        Try
            sqlDBconnection()
        Catch ex As Exception
            'If it doesnt, then it will display the error message
            Response.Write(ex.Message)
            Exit Sub

        End Try
        sqlinsert = "INSERT INTO FDXUSER(First_Name,Last_Name,Email,Station_ID,User_Name,Password,SQ_1,SA_1,SQ_2,SA_2,SQ_3,SA_3,Security_Level)Values(" & first_name.Text & "," & last_name.Text & "," & email_address.Text & ",'" & Stationident.SelectedValue & "'," & User_Name.Text & "," & password1.Text & "," & "*,*,*,*,*,*,3)"
        Try

            Sqlcommand.CommandText = sqlinsert
            Sqlcommand.Connection = Sqlconnection

            Sqlcommand.ExecuteNonQuery()
        Catch ex As Exception
            Response.Write(ex.Message)
            Exit Sub
        End Try


        'This will close the DB
        Try
            SqlDBConnectionClose()
        Catch ex As Exception
            Response.Write(ex.Message)
            Exit Sub
        End Try




        'This will close the database
        SqlDBConnectionClose()

        'Below will send out an email to the following email that was provided
        Try
            Dim theMessage As String
            password1.Text.ToUpper()
            password2.Text.ToUpper()
            theMessage = "Thank you for subscribing to the Fedex Newsletter<br/>"
            theMessage += "This email contains your membership details. Please keep it safe<br/>"
            theMessage += "If you lose this information, please contact administration to obtain this info<br/>"
            theMessage += "Below is your login information:<br/>"
            theMessage += "Username: " + User_Name.Text + "<br/>"

            If password1.Text = password2.Text Then
                theMessage += "Password: " + password1.Text + "<br/>"
            Else
                Dim ex As String = "Sorry Your first password is different from your second"
                Response.Write(ex)
                Exit Sub

            End If
            theMessage += "Thanks for using our website"

            Dim mailMessage As New MailMessage()
            mailMessage.From = "tyleryokley@hotmail.com"
            mailMessage.To = email_address.Text
            mailMessage.Subject = "Account Information"
            mailMessage.BodyFormat = MailFormat.Html
            mailMessage.Body = theMessage
            mailMessage.Priority = MailPriority.High
            SmtpMail.SmtpServer = "smtp.comcast.net"
            SmtpMail.Send(mailMessage)
            Response.Redirect("confirmreg.htm")

        Catch ex As Exception
            Response.Write(ex.Message)
            Exit Sub


        End Try
    End Sub
End Class

ctyokley,
>Format of the initialization string does not conform to specification at Index 33.
Where ?

You have put a single quote before the file name(Data Source='~\FDXDB3.mdb) which is not closed properly.

It should be like below

SqlConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source='~\FDXDB3.mdb';User ID=Admin;Password=;"

Problem Solved Thanks. Now i just get a stupid error saying that ....
"Syntax error in INSERT INTO statement. " couldn't tell you where it is at... see any problems with my insert statement that i'm blatently missing..

sqlinsert = "INSERT INTO FDXUSER(First_Name,Last_Name,Email,Station_ID,User_Name,Password,SQ_1,SA_1,SQ_2,SA_2,SQ_3,SA_3,Security_Level)Values(" & first_name.Text & "," & last_name.Text & "," & email_address.Text & ",'" & Stationident.SelectedValue & "'," & User_Name.Text & "," & password1.Text & "," & "*,*,*,*,*,*,3)"

You are only putting single quote around Stationident.SelectedValue.

Is that Station_ID the only text column in the FDXUSER table?

If irst_Name,Last_Name,Email etc.. are also text columns, then put single quoto for them.

No, sorry. what it is under the FDXUSERS all the headers are listed. its the First_Name,.... etc. Then the only reason i ahve the Station_ID as a selected value, is because.. its a drop down list. i didn't kno if that really matters or not. Anywyas so i have the db setup to enter information from a text box on all items. so they all need to be text fields...

which gets me to the next question:

i'm guessin it would look like so...

sqlinsert = "INSERT INTO FDXUSER(First_Name,Last_Name,Email,Station_ID,User_Name,Password,SQ_1,SA_1,SQ_2,SA_2,SQ_3,SA_3,Security_Level)Values(" & first_name.Text & "','" & last_name.Text & "','" & email_address.Text & "','" & Stationident.SelectedValue & "','" & User_Name.Text & "','" & password1.Text & "','" & "*,*,*,*,*,*,3)"

EDIT:

btw i got rid of some clutter in that statement. instead of having the SQ1.... and stuff i just deleted it so it looks like this:

sqlinsert = "INSERT INTO FDXUSER(First_Name,Last_Name,Email,Station_ID,User_Name,Password)Values(" & first_name.Text & "," & last_name.Text & "," & email_address.Text & ",'" & Stationident.SelectedValue & "'," & User_Name.Text & "," & password1.Text & "," & ")"

I have now solved my own question :D thanks for the original help!
I hope this helps ppl in the future.-Tyler

sqlinsert = "INSERT INTO FDXUSER (First_Name, Last_Name, Email, User_Name, [Password], Security_Level) VALUES ('" & first_name.Text & "','" & last_name.Text & "','" & email_address.Text & "','" & User_Name.Text & "','" & password1.Text & "','3')"
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.