hello ,
I am doing project insert data to table vacation, then update date into (table_infoname) user date
I am getting error by
Format of the initialization string does not conform to specification starting at index 0.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
ReportViewer_Vout.PrintDialog()
Dim Idnamev As String = Form1.NameTextBox.Text
Dim Idcivilv As String = Form1.CivilidTextBox.Text
Dim datesp10 As String = Form1.FileidTextBox1.Text
Dim eldarajah As String = Form1.EldarajahComboBox.Text
Dim jop As String = Form1.JopTextBox.Text
Dim infovacation As String = Form1.ComboBox1.Text
Dim Datestart As String = Format(Form1.DateTimePicker1DateTimePicker.Value, " yyyy/MM/dd ")
Dim Dateend As String = Format(Form1.DateTimePicker2DateTimePicker.Value, "yyyy/MM/dd")
Dim Vacationdata As String = Format(Form1.DateTimePicker3.Value, "yyyy/MM/dd")
Dim Totalva As String = Form1.TextBox5.Text
Dim El3malv As String = Form1.Markazel3malComboBox.Text
Dim Namevacation As String = "اجازة دورية"
Dim dataaddtime As String = Form1.Label44.Text
Dim CountryId As String = "Cancelled"
Dim iPAddress As String = Form1.Label29.Text
Dim orderby As String = Form1.Label41.Text
Dim namevacaback As String = Form1.Label40.Text
Dim edit As String = "إضافة"
Dim query As String = "INSERT INTO Table_vacation (infovacation,jop,datesp10,eldarajah,Idnamev,Idcivilv,Datestart,Dateend,Vacationdata,Totalva,El3malv,Namevacation,dataaddtime,iPAddress,orderby,CountryId,namevacaback,edit)
values (@infovacation,@jop,@datesp10,@eldarajah,@Idnamev,@Idcivilv,@Datestart,@Dateend,@Vacationdata,@Totalva,@El3malv,@Namevacation,@dataaddtime,@iPAddress,@orderby,@CountryId,@namevacaback,@edit)"
Using con As New SqlConnection("Data Source=GSD;Initial Catalog=kankon;Persist Security Info=True;User ID=gsd;Password=1234500;MultipleActiveResultSets=True")
Using cmd As New SqlCommand(query, con)
cmd.Parameters.AddWithValue("@datesp10", datesp10)
cmd.Parameters.AddWithValue("@eldarajah", eldarajah)
cmd.Parameters.AddWithValue("@jop", jop)
cmd.Parameters.AddWithValue("@infovacation", infovacation)
cmd.Parameters.AddWithValue("@Idnamev", Idnamev)
cmd.Parameters.AddWithValue("@Idcivilv", Idcivilv)
cmd.Parameters.AddWithValue("@Datestart", Datestart)
cmd.Parameters.AddWithValue("@Dateend", Dateend)
cmd.Parameters.AddWithValue("@Vacationdata", Vacationdata)
cmd.Parameters.AddWithValue("@Totalva", Totalva)
cmd.Parameters.AddWithValue("@CountryId", CountryId)
cmd.Parameters.AddWithValue("@El3malv", El3malv)
cmd.Parameters.AddWithValue("@Namevacation", Namevacation)
cmd.Parameters.AddWithValue("@dataaddtime", dataaddtime)
cmd.Parameters.AddWithValue("@iPAddress", iPAddress)
cmd.Parameters.AddWithValue("@orderby", orderby)
cmd.Parameters.AddWithValue("@namevacaback", namevacaback)
cmd.Parameters.AddWithValue("@edit", edit)
Dim vout2name_male1 As New ReportParameter("hid_male", True)
ReportViewer_voutop.LocalReport.SetParameters(vout2name_male1)
Dim vout2name_male12 As New ReportParameter("hide_female", False)
ReportViewer_voutop.LocalReport.SetParameters(vout2name_male12)
ReportViewer_voutop.RefreshReport()
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
Using con As New SqlConnection(query)
Using cmd As New SqlCommand("UPDATE Table_infoname SET DateTimePicker1 = @DateTimePicker1,DateTimePicker2 = @DateTimePicker2 WHERE civilid = @Civilid", con)
cmd.CommandType = CommandType.Text
cmd.Connection = con
cmd.Parameters.AddWithValue("@civilid", Idcivilv)
cmd.Parameters.AddWithValue("@DateTimePicker1", Datestart)
cmd.Parameters.AddWithValue("@DateTimePicker2", Dateend)
cmd.Connection = con
con.Open()
Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Close()
End Sub