Monday, March 26, 2012

populate datagrid

Hello,

Here is the part of my code, I need to add a datagrid and populate is from
this sql string. Can you write the rest of the code?

Dim Da As New OdbcDataAdapter
Dim Ds As New DataSet
Dim cmdSelect As New OdbcCommand

cmdSelect = Conn.CreateCommand
cmdSelect.CommandText = "SELECT * FROM myTable"

Thanks,
Jim.Hope this helps;
<code
/* ### In Web.config BEGIN ### */
<configuration
<appSettings>
<add key="IntranetConnStr_Core" value="Data
Source=<DBServerName_Here>;user
id=<UserID_Here>;password=<Password_Here>;initial catalog=<DB_Here>" />
</appSettings
/* ### In Web.config END ### */

/** Calling code BEGIN **/
Dim dvEventStatuss As New DataView
'Note! strSQLToRun = I read the SQL CMD in from a XLM file.
dvEventStatuss = Do_Get.Do_DBConnection("TBL_EventStatuss", strSQLToRun,
ConfigurationSettings.AppSettings(strConnStr), (strWhoCalledMe &
".Do_DBGridInit"), objVisitor)
With uwgOrderEventStatuss
.DataSource = dvEventStatuss
.DataBind()
end with
/** Calling code BEGIN **/

Public Function Do_DBConnection(ByVal strTBLName As String, ByVal strSQL As
String, ByVal strConnStrToUse As String, ByVal strWhoCalledMe As String,
ByVal objVisitor As clsSiteFunctions.clsUser) As DataView
Dim dvDataView As New DataView
Dim dsDataSet As New DataSet
Dim Connection As New SqlConnection

Try
strConnStrToUse = "IntranetConnStr_Core"
strSQL = "Select * FROM <TableName_Here>"
strTBLName = "TBL_TableName"

Connection.ConnectionString =
ConfigurationSettings.AppSettings(strConnStrToUse)
Dim Adapter As New SqlDataAdapter(strSQL, Connection)
Adapter.Fill(dsDataSet, strTBLName)
Connection.Open()
dvDataView.Table = dsDataSet.Tables(strTBLName)
Adapter.Dispose()
Connection.Close()
Connection.Dispose()
Catch

End Try
Do_DBConnection = dvDataView
End Function

</code
"JIM.H." wrote:

> Hello,
> Here is the part of my code, I need to add a datagrid and populate is from
> this sql string. Can you write the rest of the code?
> Dim Da As New OdbcDataAdapter
> Dim Ds As New DataSet
> Dim cmdSelect As New OdbcCommand
> cmdSelect = Conn.CreateCommand
> cmdSelect.CommandText = "SELECT * FROM myTable"
>
> Thanks,
> Jim.

0 comments:

Post a Comment