请大侠们指教下这asp.net(vb)代码哪里出问题了
下面这代码哪里出错了,请各位指教,很急~~~<%@ImportNamespace="System.Data"%><%@ImportNameSpace="System.Da...
下面这代码哪里出错了,请各位指教,很急~~~
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script language="VB" runat="server">
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Sub Page_Load(sender As System.Object, e As System.EventArgs)
dbname=server.mappath("mydata.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
myCommand = New OleDbCommand( "select top 3 * FROM table1", myConnection )
OleDbDataAdapter MyAdapter = new OleDbDataAdapter(myCommand, myConnection)
'建立DataSet对象ds;利用Adapter的Fill方法把SQL命令执行的结果倒入DataSet对象
DataSet ds = new DataSet()
MyAdapter.Fill(ds, "table1")
'TextBox1.Text = ds.Tables["table1"].Rows[0]["id"].ToString() 取出内存中的结果,在文本框显示
la5.Text = ds.Tables["table1"].Rows[0]["title"] '取出内存中的结果,在文本框显示
la6.Text = ds.Tables["table1"].Rows[0]["content"] '取出内存中的结果,在文本框显示
End Sub
</script>
<html>
<body>
<asp:label id="la5" runat="server" /><br>
<asp:label id="la6" runat="server" /><br>
</body>
</html>
我的是东拼西凑的,我是.net生手,哪里是c#还是vb的或者哪里出问题了请指引在下!万分感谢! 展开
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script language="VB" runat="server">
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Sub Page_Load(sender As System.Object, e As System.EventArgs)
dbname=server.mappath("mydata.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
myCommand = New OleDbCommand( "select top 3 * FROM table1", myConnection )
OleDbDataAdapter MyAdapter = new OleDbDataAdapter(myCommand, myConnection)
'建立DataSet对象ds;利用Adapter的Fill方法把SQL命令执行的结果倒入DataSet对象
DataSet ds = new DataSet()
MyAdapter.Fill(ds, "table1")
'TextBox1.Text = ds.Tables["table1"].Rows[0]["id"].ToString() 取出内存中的结果,在文本框显示
la5.Text = ds.Tables["table1"].Rows[0]["title"] '取出内存中的结果,在文本框显示
la6.Text = ds.Tables["table1"].Rows[0]["content"] '取出内存中的结果,在文本框显示
End Sub
</script>
<html>
<body>
<asp:label id="la5" runat="server" /><br>
<asp:label id="la6" runat="server" /><br>
</body>
</html>
我的是东拼西凑的,我是.net生手,哪里是c#还是vb的或者哪里出问题了请指引在下!万分感谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询