Using cn As New SqlConnection
cn.ConnectionString = "data source=.\sqlexpress;" & _
"attachdbfilename=|datadirectory|實驗室樣品分析.mdf;" & _
" integrated security=True;user instance=true;"
cn.Open()
Dim sqlstr As String = "selct * from 實施年度 where datepart(year, 實施開始日期) = year( now ) "
Dim cmd As New SqlClient.SqlCommand(sqlstr, cn)
Dim myreader As SqlClient.SqlDataReader
myreader = cmd.ExecuteReader()
If myreader.Read Then
實施編號CBox1.Items.Add(myreader.Item(" 實施年度編號"))
請問上列 Dim sqlstr As String = "selct * from 實施年度 where datepart(year, 實施開始日期) = year( now ) "
的語法有問題嗎?
因為偵錯到myreader = cmd.ExecuteReader()就會出現接近 * 語法錯誤訊息