SQL Anywhere错误-157:无法将'08 / 10/09'转换为时间戳

问题描述 投票:1回答:1

这里也提出了同样的问题:Getting Exception 'Cannot convert '08/10/09' to a timestamp' while connecting to Sybase Database with .Net

没有提供答案,我无法发布评论到该线程,因为我是一个新用户,所以我试图再次询问。

我正在尝试构建一个.NET应用程序来与Sybase / ASE / SQL Anywhere数据库进行通信,使用SAP上的信息:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sdk_12.5.1.adonet/html/adonet/Connecting_adodotnet_development.htm

有了所有说,这是我正在使用的代码:

private void MainWindow_Load(object sender, EventArgs e) {
        using (AseConnection con = new AseConnection("Provider=ASEOLEDB.1; Data Source=localhost; Port=2638; Database={correct db name}; Uid={correct username}; Pwd={correct password}; Charset=iso_1;")) {
            con.Open();
        }
    }

我在con.Open()上抛出一个异常:

“SQL Anywhere错误-157:无法将'08 / 10/09'转换为时间戳”

Stack Trace如下:

   at Sybase.Data.AseClient1.AseConnection.Open()
   at Sybase.Data.AseClient.AseConnection.Open()
   at ReportGenerator.MainWindow.MainWindow_Load(Object sender, EventArgs e) 
   in C:\Projects\DiCello\ReportGenerator\ReportGenerator\MainWindow.cs:line 21
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

我见过以下内容:https://archive.sap.com/discussions/thread/3646147,但这不适用,因为我没有尝试运行查询,我还不能建立连接来运行建议的查询。 8/10/09日期不是我在任何地方提交的日期。另请注意,此异常是在AseConnection.Open()上,我没有提交格式错误的日期,数据库中也没有格式错误的日期。

c# database ado.net sybase sqlanywhere
1个回答
0
投票

您似乎尝试将日期(MMDDYYYY)数据类型应用于DateTime或Time数据类型。这些本质上是包含不同信息的不同数据类型。

时间:

  • 小时(hh)
  • 分钟(mm)
  • 秒(ss)

日期:

  • 月(MM)
  • 天(DD)
  • 年(YYYY)
© www.soinside.com 2019 - 2024. All rights reserved.