Dim checi, qidian, zhongdian, sqlmsg, sqlendPrivate Sub Command1_Click()
If Text1.Text = "" Then Text1.Text = "车次"sqlend = "select 起点,终点 from gongjiaoluxian where 车次='& Text1.Text'"
With DataGrid1
.Columns(0).Caption = "车次"
End WithAdodc1.RecordSource = sqlend
Adodc1.Refresh
DataGrid1.Refresh
End SubPrivate Sub Form_Load()
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\吕志鑫\gongjiao.mdb;Persist Security Info=False"
.RecordSource = "select 车次 from gongjiaoluxian"
Set DataGrid1.DataSource = Adodc1
End With
End Sub
If Text1.Text = "" Then Text1.Text = "车次"sqlend = "select 起点,终点 from gongjiaoluxian where 车次='& Text1.Text'"
With DataGrid1
.Columns(0).Caption = "车次"
End WithAdodc1.RecordSource = sqlend
Adodc1.Refresh
DataGrid1.Refresh
End SubPrivate Sub Form_Load()
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\吕志鑫\gongjiao.mdb;Persist Security Info=False"
.RecordSource = "select 车次 from gongjiaoluxian"
Set DataGrid1.DataSource = Adodc1
End With
End Sub
sqlend = "select 起点,终点,车次 from gongjiaoluxian where 车次='& Text1.Text'"试试。
sqlend = "select 起点,终点 from gongjiaoluxian where 车次='& Text1.Text'"
改为
sqlend = "select 起点,终点 from gongjiaoluxian where 车次='" & Text1.Text & "'"
注意单引号在Sql语句中的连接。