Error with SQL Insert Into Access 2010 - mysql

I may have found the problem but at this point trying to correct it has been the issue. I have checked the source table and the insertion table and both have the correct fields/type values needed for this insert. So, my question is why am I getting an appending error in one row with this statement? I believe the only Yes/No box ( i.e. Ramp ) is causing this headache. How would I go about correcting this? Thank you very much here is the insertion statement.
DoCmd.RunSQL "INSERT INTO tblReportFinal(ProjectNo, RouteType, Route, StreetType, Direction1, Direction2, CommonDesignation, " & _
"FromRouteType, FromRoute, FromStreetType, FromCommonDesignation, ToRouteType, ToRoute,ToStreetType, ToCommonDesignation, Ramp, RampDirection, " & _
"Municipality, StartDate, StopDate, ImpactOnTravel, SuggestionsToMotorists, TrafficAlert, OtherComments, WidthRestriction, " & _
"ProjectStatus, ContractNo, Contractor, PercentComplete, GeneralOfficePhoneNumber, GeneralMobilPhoneNumber, GeneralHomePhoneNumber, ElectricalContractor, " & _
"ElectricalPhoneNumber, ContractorRep1Name, ContractorRep1OfficePhone, ContractorRep1MobilPhone, ContractorRep1HomePhone, ContractorRep2Name, ContractorRep2OfficePhone, ContractorRep2MobilPhone, " & _
"ContractorRep2HomePhone, ConsultantFirstName, ConsultantLastName, ConsultantOfficePhoneNumber, ConsultantMobilPhoneNumber, ConsultantHomePhoneNumber, ResidentFirstName, ResidentLastName, " & _
"ResidentOfficePhoneNumber, ResidentHomePhoneNumber, ResidentMobilePhoneNumber, SupervisorFirstName, SupervisorLastName, SupervisorOfficePhoneNumber, SupervisorMobilPhoneNumber, TrafficControlCompanyName, TrafficControlContactName, TrafficControlPhoneNumber, RouteTypeOrderBy) " & _
"VALUES('" & rsReportLoc("ProjectNo") & "','" & rsReportLoc("RouteType") & "','" & rsReportLoc("Route") & "','" & rsReportLoc("StreetType") & "','" & rsReportLoc("Direction1") & "','" & _
rsReportLoc("Direction2") & "','" & rsReportLoc("CommonDesignation") & "','" & rsReportLoc("FromRouteType") & "','" & rsReportLoc("FromRoute") & "','" & rsReportLoc("FromStreetType") & "', '" & _
rsReportLoc("FromCommonDesignation") & "','" & rsReportLoc("ToRouteType") & "','" & rsReportLoc("ToRoute") & "','" & rsReportLoc("ToStreetType") & "','" & rsReportLoc("ToCommonDesignation") & "', '" & rsReportLoc("Ramp") & "', '" & rsReportLoc("RampDirection") & "', '" & _
rsIn("Municipality") & "', '" & _
rsIn("StartDate") & "','" & rsIn("StopDate") & "','" & rsIn("ImpactOnTravel") & "','" & rsIn("SuggestionsToMotorists") & "','" & rsIn("TrafficAlert") & "','" & _
rsIn("OtherComments") & "','" & rsIn("WidthRestriction") & "','" & rsIn("ProjectStatus") & "','" & rsIn("ContractNo") & "','" & rsIn("Contractor") & "', '" & _
rsIn("PercentComplete") & "','" & rsIn("GeneralOfficePhoneNumber") & "','" & rsIn("GeneralMobilPhoneNumber") & "','" & rsIn("GeneralHomePhoneNumber") & "','" & rsIn("ElectricalContractor") & "', '" & _
rsIn("ElectricalPhoneNumber") & "','" & rsIn("ContractorRep1Name") & "','" & rsIn("ContractorRep1OfficePhone") & "','" & rsIn("ContractorRep1MobilPhone") & "','" & rsIn("ContractorRep1HomePhone") & "', '" & _
rsIn("ContractorRep2Name") & "','" & rsIn("ContractorRep2OfficePhone") & "','" & rsIn("ContractorRep2MobilPhone") & "','" & rsIn("ContractorRep2HomePhone") & "','" & rsIn("ConsultantFirstName") & "', '" & _
rsIn("ConsultantLastName") & "','" & rsIn("ConsultantOfficePhoneNumber") & "','" & rsIn("ConsultantMobilPhoneNumber") & "','" & rsIn("ConsultantHomePhoneNumber") & "','" & rsIn("ResidentFirstName") & "', '" & _
rsIn("ResidentLastName") & "','" & rsIn("ResidentOfficePhoneNumber") & "','" & rsIn("ResidentHomePhoneNumber") & "','" & rsIn("ResidentMobilePhoneNumber") & "','" & rsIn("SupervisorFirstName") & "','" & rsIn("SupervisorLastName") & "', '" & _
rsIn("SupervisorOfficePhoneNumber") & "','" & rsIn("SupervisorMobilPhoneNumber") & "','" & rsIn("TrafficControlCompanyName") & "','" & rsIn("TrafficControlContactName") & "','" & rsIn("TrafficControlPhoneNumber") & "', '" & RouteTypeOrder & "')"

If Ramp is an Yes/No type why are you using a String value?
, '" & rsReportLoc("Ramp") & "',
It should be simply
, " & rsReportLoc("Ramp") & ",

Related

I got syntax error in update statement.Run-time error: 3144 I use the following code

Private Sub cmdAdd_Click()
'when we Click on button Add there are two options
'1. for insert
'2. for update
If Me.txtdate.Tag & "" = "" Then
'this is for insert new
'add data to table
CurrentDb.Execute "INSERT INTO BphCore1(DateOfTesting, TestingAt, VoltageLevel, PolarityCheck, AppliedVoltageInPrimary, AppliedVoltageInSecondary, MeasurmentUnitIR, MinimumValue, PrimaryToEarth, PrimaryToSecondary,SecondaryToEarth, MeasurmentUnitWR, WRSecondaryValues, 20OfInjectedValue, 20OfMeasurmentValue, 40OfInjectedValue, 40OfMeasurmentValue, 60OfInjectedValue, 60OfMeasurmentValue, 80OfInjectedValue, 80OfMeasurmentValue, 100OfInjectedValue, 100OfMeasurmentValue, KneePointVoltage, MagnetizingCurrent) " & _
" VALUES('" & Me.txtdate & "','" & Me.cbotest & "','" & Me.cbovl & "','" & Me.cbopc & "','" & Me.cboavp & "','" & Me.cboavs & "','" & Me.cbomuir & "','" & _
Me.txtMV & "','" & Me.txtpe & "','" & Me.txtps & "','" & Me.txtse & "','" & Me.cbomuwr & "','" & Me.txtwrsv & "','" & Me.txti20 & "','" & Me.txtm20 & "','" & Me.txti40 & "','" & Me.txtm40 & "','" & Me.txti60 & "','" & Me.txtm60 & "','" & Me.txti80 & "','" & Me.txtm80 & "','" & Me.txti100 & "','" & Me.txtm100 & "','" & Me.txtkpv & "','" & Me.txtmc & "')"
Else
'otherwise (Tag of txtdate store the DateOfTesting of BphCore1 to be modified)
CurrentDb.Execute " UPDATE BphCore1 " & _
" SET DateOfTesting=" & Me.txtdate & _
", TestingAt='" & Me.cbotest & "'" & _
", VoltageLevel='" & Me.cbovl & "'" & _
", PolarityCheck='" & Me.cbopc & "'" & _
", AppliedVoltageInPrimary='" & Me.cboavp & "'" & _
", AppliedVoltageInSecondary='" & Me.cboavs & "'" & _
", MeasurmentUnitIR='" & Me.cbomuir & "'" & _
", MinimumValue='" & Me.txtMV & "'" & _
", PrimaryToEarth='" & Me.txtpe & "'" & _
", PrimaryToSecondary='" & Me.txtps & "'" & _
", SecondaryToEarth='" & Me.txtse & "'" & _
", MeasurmentUnitWR='" & Me.cbomuwr & "'" & _
", WRSecondaryValues='" & Me.txtwrsv & "'" & _
", 20OfInjectedValue='" & Me.txti20 & "'" & _
", 20OfMeasurmentValue='" & Me.txtm20 & "'" & _
", 40OfInjectedValue='" & Me.txti40 & "'" & _
", 40OfMeasurmentValue='" & Me.txtm40 & "'" & _
", 60OfInjectedValue='" & Me.txti60 & "'" & _
", 60OfMeasurmentValue='" & Me.txtm60 & "'" & _
", 80OfInjectedValue='" & Me.txti80 & "'" & _
", 80OfMeasurmentValue='" & Me.txtm80 & "'" & _
", 100OfInjectedValue='" & Me.txti100 & "'" & _
", 100OfMeasurmentValue='" & Me.txtm100 & "'" & ", KneePointVoltage='" & Me.txtkpv & "'" & ", MagnetizingCurrent='" & Me.txtmc & "'" & _
" WHERE DateOfTesting=" & Me.txtdate.Tag
End If
'clear form
cmdclean_Click
'refresh data in the list on form
BphCore1subfrm.Form.Requery
End Sub
Parameters for date/time fields use # delimiter, parameters for text fields use apostrophe delimiter, parameters for number fields do not require delimiter.
" VALUES(#" & Me.txtdate & "#,'"
" SET DateOfTesting=#" & Me.txtdate & "#" & _
" WHERE DateOfTesting=#" & Me.txtdate.Tag & "#"

MySQL query too long in vba

I have an insert MySQL query that is too long and I get error probably because I am not breaking them properly.
so here's the query
sq = "Insert into trainer (`ID`, `Site work being carried out`, `Manufacturers Serial Number or VIN`,`Platform`,`Type of Equipment`,`Equipment Sub-Grouping`,`Equipment Group`,`Equipment Description`,`NSN / Part Number`,`Manufacturer`,`Model`,`Date of Manufacture`,`Base`,`On Base Location`,`Serial Number`,`Last Odometer or Hour Meter Reading`,`Current Status`,`Equipment Arrival Date`,`Equipment ECD (Estimated Completion Date)`,`Revised Estimated Delivery Date`,`Equipment ACD (Actual Equipment Completion Date)`,`Delivered Date`,`Equipment In Program for Repair or Refurbishment`,`Remarks`,`Date Requested Induction of Equipment`,`Date Equipment Inducted into Site / Program`,`Diagnosing Start Date`,`Diagnosing End Date`,`Date Price Parts Sourcing Start`,`Date Price Parts Sourcing End`,`Date NTE Process Starts`,`Induction Cycle Process Complete Date`,`Date Proposal Sent `, `S O issued Date`,`S O No`,`Date PO Request Sent to Procurement`,`Date Foregin / International Parts Arrived at Customs`,`Date Last Part(s) Recvd at Site (last part recvd to start work)`,`Date Repair Started (After last part was recvd at site)`,`Date Repair Completed`,`Local Parts Ordered`,`Local Parts Received`,`Foreign / Int Parts Ordered`,`Foreign / Int Parts Received`) values ('" & prr.value & "','" & sitecombo.value & "','" & vin.value & "','" & ComboBox2.value & "','" & ComboBox3.value & "','" & ComboBox4.value & "','" & eqgrp.value & "','" & desc.value & "','" & nsn.value & "','" & mfg.value & "','" & mdl.value & "','" & mfgyr.value & "','" & rsafbase.value & " ','" & onbaseloc.value & "','" & rsafsr.value & "','" & odomtr.value & "','" & status.value & "','" & arvldt.value & "','" & ecd.value & "','" & redd.value & "','" & acd.value & "','" & deldt.value & "','" & vin.value & "','" & rprrfb.value & "','" & remarks.value & "','" & indreq.value & "','" & inddt.value & "','" & digdt.value & "','" & digend.value & "','" & srcdt.value & "','" & srcend.value & "','" & ntedt.value & "','" & incend.value & "','" & nteprp.value & "','" & nteapp.value & "','" & nteend.value & "','" & sodt.value & "','" & sono.value & "','" & podt.value & "','" & farvl.value & "','" & lstpartrecdt.value & "','" & rprstrt.value & "','" & rprcom.value & "','" & lclord.value & "', '" & lclrec.value & "','" & ford.value & "','" & frec.value & "');"
can someone help me please...

Microsoft access "data type mismatch in criteria expression" error

I have written code to add and edit data in a table but I am getting "data type mismatch in criteria expression".
Private Sub Submit_Click()
If Me.txtid.Tag & "" = "" Then
'add data to table
CurrentDb.Execute "INSERT INTO Client(Client_ID,Title,First_Name,Last_Name,Employer,DOB,Updated_Date,Email,Phone_Number,Mobile_Number,Address_Street,Date_of_1st_Session,Presenting_Issue,Next_Of_Kin,EAP_Number,Status,History)" & _
" VALUES('" & Me.txtid & "','" & Me.txt_title & "','" & Me.txtname & "','" & Me.txtlastname & "','" & Me.txtorg & "','" & Me.CreatedDate & "','" & Me.UpdatedDate & "','" & Me.txtEmail & "', '" & Me.txtphone & "','" & Me.txtmb & "', '" & Me.txtadd & "','" & Me.txtdate & "', '" & Me.txtissue & "','" & Me.txtnext & "','" & Me.txtEAP & "','" & Me.Combo45 & "','" & Me.txtHistory & "')"
Else
CurrentDb.Execute "UPDATE Client" & " SET Client_ID=" & Me.txtid & ", Title='" & Me.txt_title & "'" & ", First_Name='" & Me.txtname & "'" & ", Last_Name='" & Me.txtlastname & "'" & ", Employer='" & Me.txtorg & "'" & ", DOB='" & Me.CreatedDate & "'" & ", Updated_Date='" & Me.UpdatedDate & "'" & ", Email='" & Me.txtEmail & "'" & ", Phone_Number='" & Me.txtphone & "'" & ", Mobile_Number='" & Me.txtmb & "'" & ", Address_Street='" & Me.txtadd & "'" & ", Date_of_1st_Session='" & Me.txtdate & "'" & ", Presenting_Issue='" & Me.txtissue & "'" & ", Next_Of_Kin='" & Me.txtnext & "'" & ", EAP_Number='" & Me.txtEAP & "'" & ", Status='" & Me.Combo45 & "'" & ", History='" & Me.txtHistory & "'" & " WHERE Client_ID=" & Me.txtid.Tag
End If
Command39_Click
Me.txtid.SetFocus
Client_subform.Form.Requery
End Sub
You seem to be treating all the values as strings ('" & Me.txtid & "')when some of the data items may be numeric or dates.
Try ( " & Me.txtid & " ) if it's numeric or (#" & Me.CreatedDate & "#)

#22003Out of range value adjusted for column ' column name ' at row 1

I have this code in saving the record in the database
mycom.Connection = cn
mycom.CommandText = "Insert into
tbl_employee(LastName,FirstName,MiddleName,NickName,DHired,Position,Gender,Address,
Cellphone,FName,FOccupation,MName,MOccupation,DSpoken,BDate,Place,CStatus,Citizenship,
Height,Weight,Religion,EName,EContact,SSS,Pagibig,Philhealth,TIN,Spouse,SOccupation,
ChildNo,C1,A1,C2,A2,Motto,FMovie,FQuotation,FActress,FColor,Moment,FActor,PastTime,FDay,
ESchool,EYG,SSchool,SYG,CSchool,CYG,CCourse,CUG,VSchool,VYG,VCourse,MSchool,MYG,MDegree,
SSkills,STitle1,SAddress1,SDate1,STitle2,SAddress2,SDate2,STitle3,SAddress3,SDate3,
STitle4,SAddress4,SDate4,STitle5,SAddress5,SDate5) values ('" & txtLastName.Text & "','"
& txtFirstName.Text & "','" & txtMiddleName.Text & "','" & txtNickname.Text & "','" & dtpDate.Text & "','" & cboPosition.Text & "','" & cboGender.Text & "','" & txtAddress.Text
& "','" & txtCellphone.Text & "','" & txtFName.Text & "','" & txtFOccupation.Text & "','"
& txtMName.Text & "','" & txtMOccupation.Text & "','" & txtDialects.Text & "','" &
dtpBdate.Text & "','" & txtPlace.Text & "','" & cboCStatus.Text & "','" &
txtCitizenship.Text & "','" & txtHeight.Text & "','" & txtWeight.Text & "','" &
txtReligion.Text & "','" & txtEName.Text & "','" & txtEPhone.Text & "','" & txtSSS.Text &
"','" & txtPagibig.Text & "','" & txtPhilhealth.Text & "','" & txtTin.Text & "','" &
txtSpouse.Text & "','" & txtSOccupation.Text & "','" & txtChildNo.Text & "','" &
txtChild1.Text & "','" & txtAge1.Text & "','" & txtChild2.Text & "','" & txtAge2.Text &
"','" & txtMotto.Text & "','" & txtMovie.Text & "','" & txtQuotation.Text & "','" & txtActress.Text & "','" & txtColor.Text & "','" & txtMoment.Text & "','" & txtActor.Text & "','" & txtPasttime.Text & "','" & txtDay.Text & "','" & txtElemSchool.Text & "','" &
txtElemYG.Text & "','" & txtHSSchool.Text & "','" & txtHSYG.Text & "','" &
txtCollSchool.Text & "','" & txtCollYG.Text & "','" & txtCollDegree.Text & "','" &
txtYearLevel.Text & "','" & txtVocSchool.Text & "','" & txtVocYG.Text & "','" &
txtVocCourse.Text & "','" & txtEMasSchool.Text & "','" & txtEMasYG.Text & "','" &
txtEMasDegree.Text & "','" & txtSSkills.Text & "','" & txtSTTitle1.Text & "','" &
txtSTLoc1.Text & "','" & txtSTDate1.Text & "','" & txtSTTitle2.Text & "','" &
txtSTLoc2.Text & "','" & txtSTDate2.Text & "','" & txtSTTitle3.Text & "','" &
txtSTLoc3.Text & "','" & txtSTDate3.Text & "','" & txtSTTitle4.Text & "','" &
txtSTLoc4.Text & "','" & txtSTDate4.Text & "','" & txtSTTitle5.Text & "','" &
txtSTLoc5.Text & "','" & txtSTDate5.Text & "');"
myr = mycom.ExecuteReader
It always displays this error
#22003Out of range value adjusted for column 'A1' at row 1
Can anyone help me with this one
Change your datatype of age and change your query to parameterized query like this
MySqlCommand m = new MySqlCommand(readCommand);
m.Parameters.Add(new MySqlParameter("LastName", txtLastName.Text));
m.Parameters.Add(new MySqlParameter("FirstName", txtFirstName.Text));
MySqlDataReader r = m.ExecuteReader();
Assuming column A1 is supplied by txtAge1.Text.
The error is likely either A1 being the wrong type eg int and inputting abc. Does txtAge1.Text return a string or an int?
or being the type being too small eg byte and inputting 300
Prevent SQL Injection
The basic pattern according to the MySQL documentation
cmd.CommandText = "INSERT INTO myTable VALUES(NULL, #number)"
cmd.Prepare()
cmd.Parameters.AddWithValue("#number", 1)
cmd.ExecuteNonQuery()

how to vb.net date save to mysql date with no 0000-00-00

I've been killing brain cell for over 5 hours with this question.
how to properly save a date from vb.net to mysql date without getting the 0000-00-00all the time.
I have tried multiple suggestions where you format the date value before entering but it gets me the same result ex:
Dim departDate As Date
Dim d As String = Format(departDate, "05/05/2007")
in which i tested and didnt works i still got the 0000-00-00
I've tried:
Dim changeFormatDate As Date
Dim AddFechaListadoCasas2 as String
changeFormatDate = AddCasasListadoDatePicker.Text
AddFechaListadoCasas2 = changeFormatDate.ToString("yyyy-MM-dd")
which still gives me on mysql the 0000-00-00
I also tried this example:
Dim myDate as DateTime = DateTime.ParseExact(x, "yyyy-MM-dd", CultureInfo.CurrentCulture)
and trying to save to mysql still gave me the 0000-00-00
in my program im grabbing the date from a datepicker as text then swtich it to a string and try to save it to the database like that. if necessary i would love to convert it to a date with the format yyyy-MM-dd which is necessary for MySQL but everything i've done above it still shows me the 0000-00-00 which is frustrating.
any help would be very appreciated it.
Leo
here is the MySQL insert statement i have on my program.
AddFechaListadoCasas2 = AddCasasListadoDatePicker.Text
AddFechaCierreCasas2 = AddFechaCierreCasas.Text
SqlVentaCasas = "INSERT INTO VentaCasas (ID, Direccion, Ciudad_Municipio, Zona_Localidad, Barrio, " & _
"Estatus, Precio, Unidad, Departamento, Conjunto, Estrato, Matricula_Inmobiliaria, Cedula_Catastral," & _
"Escritura, Notaria, Ano, Area_Metros_2, Tipo_de_Construccion, Niveles, Habitaciones, Garajes," & _
"Techo, Vista, Picina, Cocina_Integral, Bar, Cuarto_Bano_Servicio, Antejardin, Equipos," & _
"Aire_Acondicionado, Detalles_addicionales, Estilo, Ano_Construccion, Orientacion, Banos, Parqueos," & _
"Piso, Balcon, Jacuzzi_Sauna, Chimenea, Hall_Television, Zona_lavanderia, Patio, Accesorios," & _
"Calefaccion, Administracion, Amenidades, Impuestos, Condiciones, Ocupacion," & _
"Cuota_Administracion, Restricciones, Seguridad, Mostrar, Comision, Fecha_Listado, " & _
"Agente_Cooperante, Fecha_Expiracion, CiudadEscritura, Agente, Licensia, Compania, NumeroPersonal," & _
"NumeroCompania, NumeroFax, Email, AreaLotesM2, PrecioOriginal, Account_Creator, NumeroDias ) VALUES ('" & _
AddIDCasas2 & "','" & _
AddDireccionCasas2 & "','" & AddCiudadCasas2 & "','" & AddZonaCasas2 & "','" & AddBarrioCasas2 & "','" & _
AddEstatusCasas2 & "'," & AddPrecioCasas2 & ",'" & AddUnidadCasas2 & "','" & AddDepartamentoCasas2 & "','" & _
AddConjuntoCasas2 & "'," & AddEstratoCasas2 & ",'" & AddMatriculaCasas2 & "','" & _
AddCedulaCatastralCasas2 & "','" & AddEscrituraCasas2 & "','" & AddNotariaCasas2 & "'," & _
AddAnoCasas2 & "," & AddMetros2Casas2 & ",'" & AddTipoConstruccionCasas2 & "'," & _
AddNivelesCasas2 & "," & AddHabitacionesCasas2 & "," & AddGarajesCasas2 & ",'" & _
AddTechoCasas2 & "','" & AddVistaCasas2 & "','" & AddPicinaCasas2 & "','" & AddCocinaIntegralCasas2 & "','" & _
AddBarCasas2 & "','" & AddCuartoCasas2 & "','" & AddAnteJardinCasas2 & "','" & AddEquiposCasas2 & "','" & _
AddAireAcondicionadoCasas2 & "','" & AddDetallesAddicionalesCasas2 & "','" & AddEstiloCasas2 & "'," & _
AddAnoConstruccionCasas2 & ",'" & AddOrientacionCasas2 & "'," & AddBanoCasas2 & "," & _
AddParqueoCasas2 & ",'" & AddPisoCasas2 & "','" & AddBalconCasas2 & "','" & AddJacuzziCasas2 & "','" & _
AddChimeneaCasas2 & "','" & AddTVCasas2 & "','" & AddZonaLavanderiaCasas2 & "','" & AddPatioCasas2 & "','" & _
AddAccesoriosCasas2 & "','" & AddCalefaccionCasas2 & "','" & AddAdministracionCasas2 & "','" & _
AddAmenidadesCasas2 & "','" & AddImpuestosCasas2 & "','" & AddCondicionesCasas2 & "','" & _
AddOcupacionCasas2 & "','" & AddCuotaAdministracionCasas2 & "','" & AddRestriccionesCasas2 & "','" & _
AddSeguridadCasas2 & "','" & AddMonstrarCasas2 & "','" & AddComisionCasas2 & "','" & _
AddFechaListadoCasas2 & "','" & AddAgenteCooperanteCasas2 & "','" & _
AddFecdhaExpiracionCasas2 & "','" & _
AddCiudadEscrituraCasas2 & "','" & AgenteNameCasas2 & "','" & _
AgenteLicensiaCasas2 & "','" & AgenteCompaniaCasas2 & "','" & _
AgentePersonalCasas2 & "','" & AgenteTelefonoCasas2 & "','" & _
AgenteFaxCasas2 & "','" & AgenteEmailCasas2 & "'," & AddAreaLotesM2Casas2 & "," & AddPrecioOriginalCasas2 & ", '" & AgenteAccountCreatorCasas2 & "', 0 );"
AddFechaListadoCasas2 and AddFecdhaExpiracionCasas2 are Strings that contains the date i want to input on MySQL
Your current query is vulnerable with SQL Injection. Please make use of ADONet Object such as Connection and Command with parameters. To be more specific, since you are using MySQL, use MySQL Data provider. It will automatically cast the data types for you.
Dim query As String = "INSERT INTO tableName (dateColumn) VALUES (#dateParam)"
Using conn As New MySqlConnection("connectionstringHere")
Using comm As New MySqlCommand()
With comm
.Connection = conn
.CommandText = query
.CommandType = Commandtype.Text
' Assuming this is a DatePicker '
.Parameters.AddWithValue("#dateParam", AddCasasListadoDatePicker.Value)
End With
Try
conn.Open()
comm.ExecuteNonQuery()
Catch(ex as MySqlException)
Msgbox(ex.Message.ToString())
End Try
End Using
End Using