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.....

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories