
February 7th, 2002, 10:56 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,578
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
Originally posted by : masoom (masoom_w@hotmail.com)This Example is for Access!!change the connection to SQL SERVER!!Sub Page_Load(Source As Object, E As EventArgs)Dim oConnection As ADOConnectionDim oCommand As ADODataSetCommand Dim oDS As New DataSet Dim sConnString As String Dim sSQL As String Dim nCount As Integer'Define connection string DSN less connection string.... change it withrespect to your server 'and database name sConnString = "DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & Server.MapPath("ashoknetdbempdb.mdb")'Define SQL statement sSQL = "SELECT * FROM emp"'Create the connectionoConnection = New ADOConnection(sConnString) 'Execute this SQL statement with this Connection StringoCommand = New ADODataSetCommand(sSQL, sConnString) 'Fill the DataSet and name the table oCommand.FillDataSet(oDS, "TestTable") DataGrid1.DataSource = oDS.Tables("TestTable").DefaultView DataGrid1.DataBind() End Sub
|