populate datagrid

G

Guest

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.
 
G

Guest

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top