Thanks... I did try that. I will explain the situation. Its complicated.
I have a mySQLCommandtext:
NonQueryCommand.CommandText = _
"INSERT INTO info(Date, StartTime, EndTime, TimeTaken, CompanyName, ContactName, Description, Chargeable, Rate, TotalCharges)" + _
"VALUES('?Date', '?StartTime', '?EndTime', '?TimeTaken', '?Companyname', '?ContactName', '?Description', '?Chargeable', ?Rate, ?TotalCharges)"
dont be fooled by the single ', its only to send out the names because without them i get an error. "input string is not in a correct format.
this only happens with strings right now.
this is more of the code.
NonQueryCommand.Parameters.AddWithValue("?Date", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?StartTime", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?EndTime", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?TimeTaken", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?CompanyName", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?ContactName", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?Description", MySqlDbType.Text)
NonQueryCommand.Parameters.AddWithValue("?Chargeable", MySqlDbType.VarChar)
NonQueryCommand.Parameters.AddWithValue("?Rate", MySqlDbType.Double)
NonQueryCommand.Parameters.AddWithValue("?TotalCharges", MySqlDbType.Double)
NonQueryCommand.Prepare()
For Each row As DataGridViewRow In DailyReportGrid.Rows
Dim datestring As String = row.Cells("DateColumn").Value.ToString
Dim starttimestring As String = row.Cells("StartTimeColumn").Value.ToString
Dim endtimestring As String = row.Cells("EndTimeColumn").Value.ToString
Dim timetakenstring As String = row.Cells("TimeTakenColumn").Value.ToString
Dim customernamestring As String = row.Cells("CompanyNameColumn").Value.ToString
Dim contactnamestring As String = row.Cells("ContactNameColumn").Value.ToString
Dim descriptionstring As String = row.Cells("DescriptionColumn").Value, Chr(34)
Dim chargeablestring2 As String = row.Cells("ChargeableColumn").Value.ToString
Dim ratesdecimal As Double = row.Cells("RateColumn").Value
Dim totalchargesdecimal As Double = row.Cells("TotalChargesColumn").Value
NonQueryCommand.Parameters("?Date").Value = datestring
NonQueryCommand.Parameters("?StartTime").Value = starttimestring
NonQueryCommand.Parameters("?EndTime").Value = endtimestring
NonQueryCommand.Parameters("?TimeTaken").Value = timetakenstring
NonQueryCommand.Parameters("?CompanyName").Value = customernamestring
NonQueryCommand.Parameters("?ContactName").Value = contactnamestring
NonQueryCommand.Parameters("?Description").Value = DescriptionTextBox.Text
NonQueryCommand.Parameters("?Chargeable").Value = chargeablestring
NonQueryCommand.Parameters("?Rate").Value = ratesdecimal
NonQueryCommand.Parameters("?TotalCharges").Value = totalchargesdecimal
Next
NonQueryCommand.ExecuteNonQuery()
Catch formatEx As System.FormatException
MessageBox.Show(formatEx.ToString)
Catch ex As MySqlException
MessageBox.Show(ex.ToString)
Finally
MySQLConnection.Close()
End Try
again, my code seems to be a bit much with the unnecessary variables, but i only did so to play with the strings in many different ways. the strings coming from either a textbox, or the gridcell doesnt match a proper string to enter my MySQL database. i have doubles and they go in fine, but the strings dont. any ideas?