Showing posts with label vbnet. Show all posts
Showing posts with label vbnet. Show all posts

Monday, March 26, 2012

populate array with sql table data vb.net

hello,
I wanted to populate an array with the data from sql table, but not
sure how to go about it.
This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.
Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}
Any suggestions how to go about this one. Your time is greatly
appreciated.
cheers, Sharon.Simple example (i assume you have basic knowledge about ADO.NET)
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()
End Sub
Private Const ConnectionString As String =
" server=ServerName;uid=UserName;password=
Password;database=DatebaseName"
Private Function GetDates() As System.Collections.Generic.List(Of DateTime)
Dim result As New System.Collections.Generic.List(Of DateTime)
Dim connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
Condition", connection)
Dim reader As SqlDataReader
Try
connection.Open()
reader = command.ExecuteReader()
While reader.Read()
result.Add(reader.GetDateTime(0))
End While
Catch ex As Exception
Throw ex
Finally
connection.Dispose()
End Try
Return result
End Function
End Class
Milosz Skalecki
MCP, MCAD
"Sharon" wrote:

> hello,
> I wanted to populate an array with the data from sql table, but not
> sure how to go about it.
> This is the array iam using at present, but i dont want to provide the
> values. Instead i want to query them from sql table t_holidays.
> Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
> #7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}
> Any suggestions how to go about this one. Your time is greatly
> appreciated.
> cheers, Sharon.
>
Thanks for the Reply, But its giving me an error
System.Collections.Generic.List is not defined, Please let me know
where did it went wrong.
cheers, Sharon.
Milosz Skalecki wrote:
> Simple example (i assume you have basic knowledge about ADO.NET)
> Imports System.Data
> Imports System.Data.SqlClient
> Partial Class _Default
> Inherits System.Web.UI.Page
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()
> End Sub
> Private Const ConnectionString As String =
> " server=ServerName;uid=UserName;password=
Password;database=DatebaseName"
> Private Function GetDates() As System.Collections.Generic.List(Of DateTim
e)
> Dim result As New System.Collections.Generic.List(Of DateTime)
> Dim connection As New SqlConnection(ConnectionString)
> Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
> Condition", connection)
> Dim reader As SqlDataReader
> Try
> connection.Open()
> reader = command.ExecuteReader()
> While reader.Read()
> result.Add(reader.GetDateTime(0))
> End While
> Catch ex As Exception
> Throw ex
> Finally
> connection.Dispose()
> End Try
> Return result
> End Function
> End Class
>
> --
> Milosz Skalecki
> MCP, MCAD
>
> "Sharon" wrote:
>
I am using .NET Framework version, is this class available in this
version
Milosz Skalecki wrote:
> Simple example (i assume you have basic knowledge about ADO.NET)
> Imports System.Data
> Imports System.Data.SqlClient
> Partial Class _Default
> Inherits System.Web.UI.Page
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()
> End Sub
> Private Const ConnectionString As String =
> " server=ServerName;uid=UserName;password=
Password;database=DatebaseName"
> Private Function GetDates() As System.Collections.Generic.List(Of DateTim
e)
> Dim result As New System.Collections.Generic.List(Of DateTime)
> Dim connection As New SqlConnection(ConnectionString)
> Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
> Condition", connection)
> Dim reader As SqlDataReader
> Try
> connection.Open()
> reader = command.ExecuteReader()
> While reader.Read()
> result.Add(reader.GetDateTime(0))
> End While
> Catch ex As Exception
> Throw ex
> Finally
> connection.Dispose()
> End Try
> Return result
> End Function
> End Class
>
> --
> Milosz Skalecki
> MCP, MCAD
>
> "Sharon" wrote:
>
Howdy,
i automatically assumed you were using framework 2.0. Please use
System.Collections.ArrayList instead of
System.Collections.Generic.List(Of DateTime)
regards
Milosz Skalecki
MCP, MCAD
"Sharon" wrote:

> I am using .NET Framework version, is this class available in this
> version
> Milosz Skalecki wrote:
>

populate array with sql table data vb.net

hello,

I wanted to populate an array with the data from sql table, but not
sure how to go about it.

This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.

Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}

Any suggestions how to go about this one. Your time is greatly
appreciated.

cheers, Sharon.Simple example (i assume you have basic knowledge about ADO.NET)

Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()

End Sub

Private Const ConnectionString As String =
"server=ServerName;uid=UserName;password=Password;d atabase=DatebaseName"

Private Function GetDates() As System.Collections.Generic.List(Of DateTime)

Dim result As New System.Collections.Generic.List(Of DateTime)
Dim connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
Condition", connection)
Dim reader As SqlDataReader

Try

connection.Open()
reader = command.ExecuteReader()

While reader.Read()
result.Add(reader.GetDateTime(0))
End While

Catch ex As Exception
Throw ex
Finally
connection.Dispose()
End Try

Return result

End Function

End Class

--
Milosz Skalecki
MCP, MCAD

"Sharon" wrote:

Quote:

Originally Posted by

hello,
>
I wanted to populate an array with the data from sql table, but not
sure how to go about it.
>
This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.
>
Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}
>
Any suggestions how to go about this one. Your time is greatly
appreciated.
>
cheers, Sharon.
>
>


Thanks for the Reply, But its giving me an error

System.Collections.Generic.List is not defined, Please let me know
where did it went wrong.

cheers, Sharon.

Milosz Skalecki wrote:

Quote:

Originally Posted by

Simple example (i assume you have basic knowledge about ADO.NET)
>
Imports System.Data
Imports System.Data.SqlClient
>
Partial Class _Default
Inherits System.Web.UI.Page
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
>
Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()
>
End Sub
>
Private Const ConnectionString As String =
"server=ServerName;uid=UserName;password=Password;d atabase=DatebaseName"
>
Private Function GetDates() As System.Collections.Generic.List(Of DateTime)
>
Dim result As New System.Collections.Generic.List(Of DateTime)
Dim connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
Condition", connection)
Dim reader As SqlDataReader
>
Try
>
connection.Open()
reader = command.ExecuteReader()
>
While reader.Read()
result.Add(reader.GetDateTime(0))
End While
>
Catch ex As Exception
Throw ex
Finally
connection.Dispose()
End Try
>
Return result
>
End Function
>
End Class
>
>
--
Milosz Skalecki
MCP, MCAD
>
>
"Sharon" wrote:
>

Quote:

Originally Posted by

hello,

I wanted to populate an array with the data from sql table, but not
sure how to go about it.

This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.

Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}

Any suggestions how to go about this one. Your time is greatly
appreciated.

cheers, Sharon.


I am using .NET Framework version, is this class available in this
version
Milosz Skalecki wrote:

Quote:

Originally Posted by

Simple example (i assume you have basic knowledge about ADO.NET)
>
Imports System.Data
Imports System.Data.SqlClient
>
Partial Class _Default
Inherits System.Web.UI.Page
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
>
Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()
>
End Sub
>
Private Const ConnectionString As String =
"server=ServerName;uid=UserName;password=Password;d atabase=DatebaseName"
>
Private Function GetDates() As System.Collections.Generic.List(Of DateTime)
>
Dim result As New System.Collections.Generic.List(Of DateTime)
Dim connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
Condition", connection)
Dim reader As SqlDataReader
>
Try
>
connection.Open()
reader = command.ExecuteReader()
>
While reader.Read()
result.Add(reader.GetDateTime(0))
End While
>
Catch ex As Exception
Throw ex
Finally
connection.Dispose()
End Try
>
Return result
>
End Function
>
End Class
>
>
--
Milosz Skalecki
MCP, MCAD
>
>
"Sharon" wrote:
>

Quote:

Originally Posted by

hello,

I wanted to populate an array with the data from sql table, but not
sure how to go about it.

This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.

Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}

Any suggestions how to go about this one. Your time is greatly
appreciated.

cheers, Sharon.


Howdy,

i automatically assumed you were using framework 2.0. Please use
System.Collections.ArrayList instead of
System.Collections.Generic.List(Of DateTime)

regards

--
Milosz Skalecki
MCP, MCAD

"Sharon" wrote:

Quote:

Originally Posted by

I am using .NET Framework version, is this class available in this
version
Milosz Skalecki wrote:

Quote:

Originally Posted by

Simple example (i assume you have basic knowledge about ADO.NET)

Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim dates As System.Collections.Generic.List(Of DateTime) = GetDates()

End Sub

Private Const ConnectionString As String =
"server=ServerName;uid=UserName;password=Password;d atabase=DatebaseName"

Private Function GetDates() As System.Collections.Generic.List(Of DateTime)

Dim result As New System.Collections.Generic.List(Of DateTime)
Dim connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand("select DateColumn FROM TableName WHERE
Condition", connection)
Dim reader As SqlDataReader

Try

connection.Open()
reader = command.ExecuteReader()

While reader.Read()
result.Add(reader.GetDateTime(0))
End While

Catch ex As Exception
Throw ex
Finally
connection.Dispose()
End Try

Return result

End Function

End Class

--
Milosz Skalecki
MCP, MCAD

"Sharon" wrote:

Quote:

Originally Posted by

hello,
>
I wanted to populate an array with the data from sql table, but not
sure how to go about it.
>
This is the array iam using at present, but i dont want to provide the
values. Instead i want to query them from sql table t_holidays.
>
Dim HolidayList() As Date = {#7/4/2006#, #7/6/2006#, #7/13/2006#,
#7/19/2006#, #12/24/2006#, #12/25/2006#, #12/29/2006#, #1/1/2007#}
>
Any suggestions how to go about this one. Your time is greatly
appreciated.
>
cheers, Sharon.
>
>


>
>

Saturday, March 24, 2012

Populate Excell Sheet using ASP.NET/VB.NET

I have an Excel sheet that I want to be able to make changes to it
using ASP/VB.NET (like updating cells values and maybe formulas). Once
it's done; I want to save it and then launch the changed file to the
user.

How do I do that? Any examples available?"No_Spam" <no_to_spam@.comcast.netwrote in message
news:1169488289.448842.193250@.m58g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>I have an Excel sheet that I want to be able to make changes to it
using ASP/VB.NET (like updating cells values and maybe formulas). Once
it's done; I want to save it and then launch the changed file to the
user.
>
How do I do that? Any examples available?


http://www.aspose.com/Products/Aspo...ls/Default.aspx
This might be your best bet. You can open Excel as an ADO.NET data source:
http://groups.google.com/group/micr...71439ff12d7473d
Here are some other articles that may help as well:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeExcel.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"No_Spam" <no_to_spam@.comcast.netwrote in message
news:1169488289.448842.193250@.m58g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>I have an Excel sheet that I want to be able to make changes to it
using ASP/VB.NET (like updating cells values and maybe formulas). Once
it's done; I want to save it and then launch the changed file to the
user.
>
How do I do that? Any examples available?
>

Populate Excell Sheet using ASP.NET/VB.NET

I have an Excel sheet that I want to be able to make changes to it
using ASP/VB.NET (like updating cells values and maybe formulas). Once
it's done; I want to save it and then launch the changed file to the
user.
How do I do that? Any examples available?"No_Spam" <no_to_spam@.comcast.net> wrote in message
news:1169488289.448842.193250@.m58g2000cwm.googlegroups.com...

>I have an Excel sheet that I want to be able to make changes to it
> using ASP/VB.NET (like updating cells values and maybe formulas). Once
> it's done; I want to save it and then launch the changed file to the
> user.
> How do I do that? Any examples available?
http://www.aspose.com/Products/Aspo...ls/Default.aspx
This might be your best bet. You can open Excel as an ADO.NET data source:
http://groups.google.com/group/micr...71439ff12d7473d
Here are some other articles that may help as well:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeExcel.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"No_Spam" <no_to_spam@.comcast.net> wrote in message
news:1169488289.448842.193250@.m58g2000cwm.googlegroups.com...
>I have an Excel sheet that I want to be able to make changes to it
> using ASP/VB.NET (like updating cells values and maybe formulas). Once
> it's done; I want to save it and then launch the changed file to the
> user.
> How do I do that? Any examples available?
>