Hello There,
I have created a Project for my department to speed up our work and I am using VB.net 2008 and I have created a form that contains labels textboxes to be saved in the database table. Also, I have created many quarries to save the data in a table called Item, but my main problem is when I define the date to post it in the item table the vb.net refuse It so I have decided to ask in this website.
Also, I want to save a list of MFR witch its going to be entered by the user. can you help me with this as well ?
The codes as the following:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim a As String = TextBox1.Text
Dim b As String = TextBox6.Text
Dim c As String = TextBox2.Text
Dim d As String = TextBox3.Text
Dim f As String = TextBox4.Text
Dim g As String = Listbox1.text
Dim h As String = 1
Dim i As string = 2
Dim j As String = 3
Dim dt As Date = Today()
If (a = Nothing) Or (b = Nothing) Or (c = Nothing) Or (d = Nothing) Or (f = Nothing) Or (g = Nothing) Then
MsgBox("Please Fill the Fields")
ElseIf (ItemTableAdapter1.Checkitem(TextBox1.Text) = Nothing) And (RadioButton1.Checked = True) Then
Select Case (MsgBox("Are you sure you want to save this item for EDD", MsgBoxStyle.YesNo))
Case MsgBoxResult.Yes
ItemTableAdapter1.AddItem(a, b, c, d, f, g, h, dt)
MsgBox("A new item has been added")
Case MsgBoxResult.No
MsgBox("Item not Saved")
End Select
ElseIf (ItemTableAdapter1.Checkitem(TextBox1.Text) = Nothing) And (RadioButton2.Checked = True) Then
Select Case (MsgBox("Are you sure you want to save this item for WDD", MsgBoxStyle.YesNo))
Case MsgBoxResult.Yes
ItemTableAdapter1.AddItem(a, b, c, d, f, g, i, dt)
AddItem2.Show()
Me.Hide()
Case MsgBoxResult.No
MsgBox("Item not Saved")
End Select
ElseIf (ItemTableAdapter1.Checkitem(TextBox1.Text) = Nothing) And (RadioButton3.Checked = True) Then
Select Case (MsgBox("Are you sure you want to save this item for Other", MsgBoxStyle.YesNo))
Case MsgBoxResult.Yes
ItemTableAdapter1.AddItem(a, b, c, d, f, g, j, dt)
AddItem2.Show()
Me.Hide()
Case MsgBoxResult.No
MsgBox("Item not Saved")
End Select
Else
MsgBox("This Item Is already exist")
End If
End Sub
INSERT INTO Item
([N-S-NNumber], Title, Description, Specification, Guarantee, MFR, Directorate, Date)
VALUES ('@N-S-NNumber',@Title,@Description,@Specification,@Guarantee,@MFR,@Directorate,@Date)
And I changed the format in the table to datetime