|
-
Mar 1st, 2003, 05:57 PM
#1
Thread Starter
Member
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.....
-
Mar 1st, 2003, 06:48 PM
#2
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.
-
Mar 2nd, 2003, 12:51 AM
#3
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|