主题:用户代码未处理
我是asp.net初学者,用的是vb,运行程序时提示用户代码未处理,代码如下:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' 定义是否是 SQL Server 数据库,这里为False
Dim blnIsSQLServer As System.Boolean = 0
Dim strSQL As String
Dim objDataset As New DataSet
Dim objConn As Object
Dim strCnn As String
If blnIsSQLServer Then
strCnn = "User ID=rwimage;Initial Catalog=Northwind;Server=20100922-1215\express"
objConn = New System.Data.SqlClient.SqlConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter
strSQL = "Select * from customers where country='USA'"
objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
Else
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("mydb.mdb")
objConn = New System.Data.OleDb.OleDbConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.OleDb.OleDbDataAdapter
strSQL = "Select Top 10 Title From Document"
objAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
End If
请高手指点
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' 定义是否是 SQL Server 数据库,这里为False
Dim blnIsSQLServer As System.Boolean = 0
Dim strSQL As String
Dim objDataset As New DataSet
Dim objConn As Object
Dim strCnn As String
If blnIsSQLServer Then
strCnn = "User ID=rwimage;Initial Catalog=Northwind;Server=20100922-1215\express"
objConn = New System.Data.SqlClient.SqlConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter
strSQL = "Select * from customers where country='USA'"
objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
Else
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("mydb.mdb")
objConn = New System.Data.OleDb.OleDbConnection(strCnn)
objConn.Open()
Dim objAdapter As New System.Data.OleDb.OleDbDataAdapter
strSQL = "Select Top 10 Title From Document"
objAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL, objConn)
objAdapter.Fill(objDataset)
End If
请高手指点