Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

SqlClient DataView - << VB.NET VERSION >>


Popolare un DataView utilizzando SqlClient

Pupulate a DataView using SqlClient

<%@ Page language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sConn = new SqlConnection("workstation id=Intranet;packet size=4096;
user id=USERID;data source=DATABASESERVER;persist security info=True;
initial catalog=DATABASE;password=PASSWORD");
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.TableMappings.Add("Table", "[myTable]");
sConn.Open();
SqlCommand sCmd = new SqlCommand("SELECT myField FROM [myTable]", sConn);
sCmd.CommandType = CommandType.Text;
myAdapter.SelectCommand = sCmd;
DataSet ds = new DataSet("[myTable]");
myAdapter.Fill(ds);
DataView dv = new DataView(ds.Tables[0]);
dg1.DataSource = dv;
Page.DataBind();
}
</script>
</HEAD>
<body>
<asp:DataGrid id="dg1" runat="server" />
</body>
</HTML>



Download Code...


Print Page


 








Page top

risorse per webmaster