1

stored procedure私は示されているように私の中に書き込もうとしてsql commandいます:

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.

4

2 に答える 2

0

連結された SQL 文字列は次のようになります

convert(varchar(10), a.starttime,101) = 08/22/1954

これは、日付ではなく数値になる除算のシーケンスです。

値を引用符で囲んで日付リテラルを作成します。
(または、さらに良いことに、パラメーターを使用します)

于 2013-07-07T16:22:02.330 に答える