Results 1 to 3 of 3

Thread: Stuck on Data Declaration " SSN & Phone for DB

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54

    Stuck on Data Declaration " SSN & Phone for DB

    Hello. I want to pass values to a back end Access DB from a windows form. Except I seem to be stuck w/ passing values for a Social Security and Phone number. I have them defined as long integers through the dataset schema. Here is the code I am using to pass the values:


    Try
    Dim tblapdb As DataTable
    tblapdb = Dsapdb1.Tables("aptbl")
    Dim drCurrent As DataRow
    drCurrent = tblapdb.NewRow

    drCurrent("Date") = DateTimePicker1.Text
    drCurrent("SSN") = TextBox5.Text 'NOT WORKING (Also Primary Key)
    drCurrent("First") = TextBox1.Text
    drCurrent("Last") = TextBox2.Text
    If RadioButton1.Checked = True Then
    drCurrent("Hired") = "Yes"
    End If
    If RadioButton2.Checked = True Then
    drCurrent("Hired") = "No"
    End If

    drCurrent("Phone") = TextBox3.Text ' NOT WORKING
    drCurrent("Shift") = TextBox4.Text
    drCurrent("Comments") = ComboBox1.Text
    tblapdb.Rows.Add(drCurrent)
    OleDbDataAdapter1.Update(Dsapdb1)
    MsgBox("Record Added", MsgBoxStyle.Information, "Application Manager")


    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical)

    End Try
    ComboBox1.Text = ""
    TextBox1.Clear()
    TextBox2.Clear()
    TextBox3.Clear()
    TextBox4.Clear()
    TextBox5.Clear()
    OleDbConnection1.Close()

    End Sub

    Also would this SQL stmt format the SSN (ex: 123-45-6789) & Phone number correctly:

    SELECT FORMAT(SSN), '###-##-####') AS SSN, FORMAT(Phone),'###-###-####') AS Phone
    FROM aptbl

    What am I missing? Someone please advise.....

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you are going store them in the DB with the "-" marks then you'll have to make the DB datatype a string/text since "-" is not consistant with an interger. Same thing for the phone number.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54
    Thanks for the advice! What if want to pass the values (SSN & phone #) without the dash? Using the code i posted still gives me an error message: "Input String was not in correct format". Do you see anything wrong w/ my code Edneeis?

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