我写的小的WEB页代码如下,
Imports System.data.oledb
Public Class test1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False '在此处放置初始化页的用户代码
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
Label3.Visible() = True
ElseIf TextBox2.Text = "" Then
Label4.Visible() = True
Else
Dim i As Short
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim sql As String
Dim str
str = "SELECT * from aa where a='1'"
sql = "Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\dp2\db1.mdb;"
con = New OleDbConnection(sql)
con.Open()
com = New OleDbCommand(str, con)
i = com.ExecuteNonQuery()
If (i <= 0) Then
Label5.Visible = True
Else
str = "insert into aa values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
sql = "Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\dp2\db1.mdb;"
con = New OleDbConnection(sql)
con.Open()
com = New OleDbCommand(str, con)
com.ExecuteNonQuery()
End If
End If
End Sub
End Class
现在碰到这么一个问题,在代码中insert这句可以执行,可是SELECT这句不管我的ACCESS数据库里面有没有相应的内容
执行返回来的值总是0,请问为什么
写WEB程序碰到的问题