【发布时间】:2016-01-10 14:53:33
【问题描述】:
我对以下代码有困难。我认为它存在于我的 sql 语句中。 我得到错误:
操作数类型冲突:日期与 int 不兼容
Dim strSql5 As String = "SELECT * FROM dbo.ontledings where plaasblok = '" & plaasblokparsversoeke & "' and analisedatum = " & laastedatum.Date
MsgBox(strSql5)
Dim dtb5 As New DataTable
dtb5.Clear()
Using cnn As New SqlConnection("Data Source=GIDEON-E-LAPTOP\SQLEXPRESS2014;Initial Catalog=SkeduleringDatabasis;Integrated Security=True")
cnn.Open()
Using dad5 As New SqlDataAdapter(strSql5, cnn)
dad5.Fill(dtb5)
End Using
cnn.Close()
End Using
Dim laasteontleding As Decimal = dtb5.Rows(0)("suiker")
我从以下代码中得到了 laastedatum:
Dim laastedatum As Date = dtb4.Rows(0)("last")
任何帮助将不胜感激。
问候
【问题讨论】:
-
你在哪一行得到了错误?
-
不要使用字符串连接来构建 Sql 查询。这是我在您上一个问题中谈到的问题之一
标签: sql-server vb.net