求助!辛苦了!

我要一个VB例子,查询一个SQL语句,只要返回是否有匹配的内容?(不要存储过程access数据库)
辛苦了~~~先感谢了!
[67 byte] By [chhlyy] at [2008-1-9]
# 1
新年快乐,
等明年再回答这个问题。
# 2
Shared Function selsql(ByRef sql As String) As Boolean
Dim b As Boolean = False
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand()
conn.ConnectionString = ConfigurationManager.ConnectionStrings("AccessConn").ConnectionString
Dim reader As OleDbDataReader
Dim previousConnectionState As ConnectionState = conn.State
cmd.Connection = conn
cmd.CommandText = sql
conn.Open()
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
reader = cmd.ExecuteReader()
Using reader
While reader.Read()
If reader.Item(0).ToString() > 0 Then
b = True
End If
End While
End Using
Catch ex As Exception
Finally
If previousConnectionState = ConnectionState.Closed Then
conn.Close()
End If
End Try
Return b
End Function
是不是要这样的
# 3
新年快乐
Joker_myth at 2007-9-30 > top of Msdn China Tech,.NET技术,ASP.NET...
# 4
Dim bRet as Boolean = Flase cnn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\河南省论文评审信息管理系统\text.mdb") Dim cmd As OleDbCommand cmd = New OleDbCommand("select 1 from 表 where 条件") cmd.Connection = cnn cnn.Open() if (cmd.ExecuteScalar() <> DBNull.Value then bRet = true END IF dr.Close() cnn.Close() dr = Nothing cmd = Nothing cnn = Nothing
cpp2017-慕白兄 at 2007-9-30 > top of Msdn China Tech,.NET技术,ASP.NET...
# 5
谢谢了!十分感谢!呵呵
chhlyy at 2007-9-30 > top of Msdn China Tech,.NET技术,ASP.NET...
# 6
还不会怎么给分呢!研究```研究```
chhlyy at 2007-9-30 > top of Msdn China Tech,.NET技术,ASP.NET...