Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql VB中的日期重排_Mysql_Vb.net_Date - Fatal编程技术网

Mysql VB中的日期重排

Mysql VB中的日期重排,mysql,vb.net,date,Mysql,Vb.net,Date,我正在使用Visual Studio 2012在VB中构建一个预订服务,它使用一个数据库。我想知道如何将日期从VB格式(“MM-dd-yyyy”)重新排列为MySQL日期格式(“YY-MM-dd”)。任何建议都将不胜感激:)日期。ToString方法允许您指定格式: Dim d = Date.Now d.ToString("yyyy-MM-dd") 但是,最好使用参数化命令,使用实际的Date变量,让系统为您进行转换,因为您需要的实际字符串格式将取决于您当前的区域性。例如: Dim d = D

我正在使用Visual Studio 2012在VB中构建一个预订服务,它使用一个数据库。我想知道如何将日期从VB格式(“MM-dd-yyyy”)重新排列为MySQL日期格式(“YY-MM-dd”)。任何建议都将不胜感激:)

日期。ToString方法允许您指定格式:

Dim d = Date.Now
d.ToString("yyyy-MM-dd")
但是,最好使用参数化命令,使用实际的
Date
变量,让系统为您进行转换,因为您需要的实际字符串格式将取决于您当前的区域性。例如:

Dim d = Date.Now
Using command As IDbCommand = connection.CreateCommand()
    command.CommandText = "UPDATE Table SET Column = @ColumnValue"
    Dim parameter As IDbDataParameter = command.CreateParameter()
    parameter.ParameterName = "@ColumnValue"
    parameter.Value = d
    command.Parameters.Add(parameter)
    command.ExecuteNonQuery()
End Using