【发布时间】:2013-07-07 16:17:45
【问题描述】:
我正在尝试在我的 sql command 中写入 stored procedure,如图所示:
Dim tdate As String = Me.PresentDate.Value.ToString("MM-dd-yyyy")
myCommand As New SqlCommand("select c.description as 'provider',b.lastname,
b.firstname, b.middleinitial,convert(varchar(10),b.dob,101) as DOB,
b.chartID,b.sex, d.businessname,d.businessfax from patientappointmentbase as a,
patientlistbase as b,resourcebase as c, locationbase as d where convert(varchar(10),
a.starttime,101) = " & tdate & "
and a.patientid = b.patientid and a.resourceid = c.resourceid and
a.locationid = d.locationid order by provider, lastname, firstname", myConnection)
当我运行这段代码时,我得到的错误是
Conversion failed when converting the varchar value '08/22/1954' to data type int.
【问题讨论】:
-
您确定这条消息是指“tdate”变量吗?我看到另一个转换,消息中的值似乎是 DOB 而不是开始时间
-
@steve-yes...我敢肯定,因为我给出了具体的日期而不是 tdate,而且效果很好..
标签: vb.net date stored-procedures sqlcommand