List Info

Thread: Bind data to page with sql data source




Bind data to page with sql data source
country flaguser name
United States
2007-09-21 15:47:13

Hey guys looking for a way to do this rather then bind to control.

Looked on MS no luck in finding something that makes sense and Google
this time did not work out.

Any one suggest a simple tutorial or block of code?

Thanks guys.

Tony Trapp
http://www.dbtweb.com

__._,_.___
.

__,_._,___
Re: Bind data to page with sql data source
country flaguser name
United States
2007-09-21 15:56:26

What are you trying to bind it into? Dataset, dataview?

Here is one example:
Dim strConn as string ="server=yourserver.orcsweb.com;uid=student;pwd=magic"

Dim strSQL as string ="select * from publishers where state='NY'"
Dim Conn as New SQLConnection(strConn)
Dim Cmd as New SQLDataAdapter(strSQL,Conn)
Dim ds As New DataSet()
Conn.Open()
cmd.Fill(ds,"pubs")
Dim dv1 As new DataView(ds.Tables(0))
dv1.Sort = "Address"
dv1.RowFilter = "city='Albany'"

myDataGrid.DataSource = dv1
myDataGrid.DataBind()
Conn.close()

'----------------------- Here is another using a Generic List

Public Shared Function GetplannerList1() As List(Of posku_dataMain)

Dim sSelect As String = ""

Dim todaysString = "1" & Right(Today.Year.ToString, 2) &
Today.Month().ToString.PadLeft(2,
"0") & Today.Date.Day.ToString.PadLeft(2, "0")

sSelect = " myselect statement went here "

Dim PlannerList1 As New List(Of posku_dataMain)

Using conn As OdbcConnection = New OdbcConnection(Config.ConnectionString)

Using cmd As OdbcCommand = New OdbcCommand(sSelect, conn)

cmd.CommandType = CommandType.Text

conn.Open()

Using dr As OdbcDataReader = cmd.ExecuteReader()

While dr.Read() = True

Dim pod1 As New posku_dataMain()

pod1.Buyer = Trim(dr.Item("PLAN43S";))

PlannerList1.Add(pod1)

End While

End Using

End Using

End Using

Return PlannerList1

End Function

On 9/21/07, Tony Trapp < tonyt%40designbytony.com">tonytdesignbytony.com>; wrote:
&gt;
> Hey guys looking for a way to do this rather then bind to control.
>
>; Looked on MS no luck in finding something that makes sense and Google
&gt; this time did not work out.
>;
> Any one suggest a simple tutorial or block of code?
&gt;
> Thanks guys.
&gt;
> Tony Trapp
&gt; http://www.dbtweb.com
>
>
>

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )