Les envío un ejemplo para ver una base de Access y de SQL en ASP.NET beta 2,
ya que en muchos códigos que vi en internet usan System.Data.Ole,
System.Data.SQL, SQLDataSetCommand, ADODataSetCommand, FillDataset y otros
cosas que cambian con respecto al beta 1.
Saludos para todos Mariano
***************************USO CON ACCESS ******************************
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
</head>
<body>
<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
Dim oConnection As OleDbConnection
Dim oCommand As OleDbDataAdapter
Dim oDS As New DataSet
Dim sConnString As String
Dim sSQL As String
Dim nCount As Integer
'Define connection string
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\aspxexamples\database\test1.mdb") & ";" &
_
"Persist Security Info=False"
'Define SQL statement
sSQL = "SELECT * FROM Test1"
'Create the connection
oConnection = New OleDbConnection(sConnString)
'Execute this SQL statement with this Connection String
oCommand = New OleDbDataAdapter(sSQL, sConnString)
'Fill the DataSet and name the table
oCommand.Fill(oDS, "TestTable")
DataGrid1.DataSource = oDS.Tables("TestTable").DefaultView
DataGrid1.DataBind()
Response.Write("<font face=Arial size=2>")
Dim tTable As DataTable
Dim rRow As DataRow
Dim cColumn As DataColumn
'This function loops through all the tables in our tables
'collection and then loops through each of those tables
'and prints out the columns.
For Each tTable in oDS.Tables
For Each rRow In tTable.Rows
For Each cColumn in tTable.Columns
Response.Write(rRow(cColumn.ColumnName) & "<br>")
Next cColumn
Next rRow
Next tTable
Response.Write("-------------------------------<br><br>")
'To get to a specific table and row we would do this
Response.Write(oDS.Tables("TestTable").Rows(0)("FirstName") & _
"<br><br>")
End Sub
</script>
<asp:DataGrid id="DataGrid1" runat="server"/>
</body>
</html>
***************************USO CON SQL ******************************
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<script language="VB" runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New
SqlConnection("server=(local)\NetSDK;database=pubs;Trusted_Connection=yes")
MyCommand = New SqlDataAdapter("select * from Titles where type='"
+ Category.SelectedItem.Value + "'", myConnection)
DS = new DataSet()
MyCommand.Fill(DS, "Titles")
MyList.DataSource = DS.Tables("Titles").DefaultView
MyList.DataBind()
End Sub
</script>
<body>
<center>
<form action="intro8.aspx" method="post" runat="server">
<asp:adrotator AdvertisementFile="ads.xml" BorderColor="black"
BorderWidth=1 runat="server"/>
<h3> Name: <asp:textbox id="Name" runat="server"/>
Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem >psychology</asp:listitem>
<asp:listitem >business</asp:listitem>
<asp:listitem >popular_comp</asp:listitem>
</asp:dropdownlist>
</h3>
<asp:button text="Lookup" OnClick="SubmitBtn_Click"
runat="server"/>
<p>
<ASP:DataGrid id="MyList" HeaderStyle-BackColor="#aaaadd"
BackColor="#ccccff" runat="server"/>
</form>
</center>
</body>
</html>