Showing posts with label records. Show all posts
Showing posts with label records. Show all posts

Monday, March 26, 2012

Populate a dropdown list with a variable from a Querystring

Hi,

I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:

<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"

I tried moving the querystring outside the page load but that didn't work:

This is the code I have:

<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %
<script runat="server"
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )

End If
End Sub

Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)

Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)

dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

Return dataReader
End Function

Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub

</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button
</form>
</body>
</html
Thanks for any help

--
Message posted via http://www.dotnetmonster.comHi Jim,

I understood your probleim in the following way after reading your code...

You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?

If I'm right...then solution for your problem is...

Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.

Cheers,

Jerome. M

"Jim via DotNetMonster.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sure
> how to pass that value. I get the error that IntCourseID is not declared in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.

Regards
Malik Asif
ASP.NET,VB.NET

"Jim via DotNetMonster.com" <forum@.DotNetMonster.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.DotNetMonste r.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com

Populate a dropdown list with a variable from a Querystring

Hi,
I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:
<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"
I tried moving the querystring outside the page load but that didn't work:
This is the code I have:
<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )
End If
End Sub
Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub
</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button>
</form>
</body>
</html>
Thanks for any help
Message posted via http://www.webservertalk.comHi Jim,
I understood your probleim in the following way after reading your code...
You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?
If I'm right...then solution for your problem is...
Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.
Cheers,
Jerome. M
"Jim via webservertalk.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sur
e
> how to pass that value. I get the error that IntCourseID is not declared i
n:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server
"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com
>
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.
Regards
Malik Asif
ASP.NET,VB.NET
"Jim via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.Do
webservertalk.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com

Populate an Array with DB records

Hi Friends,
How can I populate an Array with the information of an Table in SQL?
Thanks... and sorry my english...
Grillo"Guilherme Grillo" <webdev@.rncomtotal.com.br> wrote in message
news:usThK6uIIHA.1212@.TK2MSFTNGP05.phx.gbl...

> How can I populate an Array with the information of an Table in SQL?
http://www.google.co.uk/search?hl=e...br />
st&meta=
Mark Rae
ASP.NET MVP
http://www.markrae.net
Thank you Mark Rae...
Solve my problem!
Now I have another problem.
try
{
int[] pointList = new Int32[60];
int[] idList = new Int32[60];
int i;
for (i = 1; i <= 57; i++)
{
// Cria o comando que seleciona os resultados atuais
commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
"", conn);
// Executa o comando e coloca os resultados em uma Matriz
conn.Open();
readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);
readerSELECT.Read();
pointList[i] = readerSELECT["contResults"];
idList[i] = readerSELECT["id"];
readerSELECT.Close();
Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
conversion exists (are you missing a cast?)
How can I convert this type'
Here I have the same error:
*int[] respostasList = new Int32[20];
respostasList[1] = RadioButtonList1.SelectedItem.Value;
Sorry my english and thanks again.
Grillo
"Mark Rae [MVP]" <mark@.markNOSPAMrae.net> wrote in message
news:OgWpENvIIHA.4296@.TK2MSFTNGP04.phx.gbl...
> "Guilherme Grillo" <webdev@.rncomtotal.com.br> wrote in message
> news:usThK6uIIHA.1212@.TK2MSFTNGP05.phx.gbl...
>
> http://www.google.co.uk/search?hl=e... />
list&meta=
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Problem Solved!
Thanks everybody...
Grillo
ps: sorry my english..
"Guilherme Grillo" <webdev@.rncomtotal.com.br> wrote in message
news:uJeouewIIHA.4712@.TK2MSFTNGP04.phx.gbl...
> Thank you Mark Rae...
> Solve my problem!
> Now I have another problem.
>
> try
> {
> int[] pointList = new Int32[60];
> int[] idList = new Int32[60];
> int i;
> for (i = 1; i <= 57; i++)
> {
> // Cria o comando que seleciona os resultados atuais
> commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
> "", conn);
> // Executa o comando e coloca os resultados em uma Matriz
> conn.Open();
> readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);
> readerSELECT.Read();
> pointList[i] = readerSELECT["contResults"];
> idList[i] = readerSELECT["id"];
> readerSELECT.Close();
>
> Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
> conversion exists (are you missing a cast?)
> How can I convert this type'
> Here I have the same error:
> *int[] respostasList = new Int32[20];
> respostasList[1] = RadioButtonList1.SelectedItem.Value;
>
> Sorry my english and thanks again.
> Grillo
> "Mark Rae [MVP]" <mark@.markNOSPAMrae.net> wrote in message
> news:OgWpENvIIHA.4296@.TK2MSFTNGP04.phx.gbl...
>

Populate an Array with DB records

Hi Friends,

How can I populate an Array with the information of an Table in SQL?

Thanks... and sorry my english...

Grillo"Guilherme Grillo" <webdev@.rncomtotal.com.brwrote in message
news:usThK6uIIHA.1212@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

How can I populate an Array with the information of an Table in SQL?


http://www.google.co.uk/search?hl=e...Arraylist&meta=
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Thank you Mark Rae...

Solve my problem!

Now I have another problem.

try

{

int[] pointList = new Int32[60];

int[] idList = new Int32[60];

int i;

for (i = 1; i <= 57; i++)

{

// Cria o comando que seleciona os resultados atuais

commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
"", conn);

// Executa o comando e coloca os resultados em uma Matriz

conn.Open();

readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConn ection);

readerSELECT.Read();

pointList[i] = readerSELECT["contResults"];

idList[i] = readerSELECT["id"];

readerSELECT.Close();

Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
conversion exists (are you missing a cast?)

How can I convert this type??

Here I have the same error:

*int[] respostasList = new Int32[20];

respostasList[1] = RadioButtonList1.SelectedItem.Value;

Sorry my english and thanks again.

Grillo

"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
news:OgWpENvIIHA.4296@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

"Guilherme Grillo" <webdev@.rncomtotal.com.brwrote in message
news:usThK6uIIHA.1212@.TK2MSFTNGP05.phx.gbl...
>

Quote:

Originally Posted by

>How can I populate an Array with the information of an Table in SQL?


>
http://www.google.co.uk/search?hl=e...Arraylist&meta=
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Problem Solved!

Thanks everybody...
Grillo

ps: sorry my english..

"Guilherme Grillo" <webdev@.rncomtotal.com.brwrote in message
news:uJeouewIIHA.4712@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Thank you Mark Rae...
>
Solve my problem!
>
Now I have another problem.
>
>
try
>
{
>
int[] pointList = new Int32[60];
>
int[] idList = new Int32[60];
>
int i;
>
for (i = 1; i <= 57; i++)
>
{
>
// Cria o comando que seleciona os resultados atuais
>
commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
"", conn);
>
// Executa o comando e coloca os resultados em uma Matriz
>
conn.Open();
>
readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConn ection);
>
readerSELECT.Read();
>
pointList[i] = readerSELECT["contResults"];
>
idList[i] = readerSELECT["id"];
>
readerSELECT.Close();
>
>
Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
conversion exists (are you missing a cast?)
>
How can I convert this type??
>
Here I have the same error:
>
*int[] respostasList = new Int32[20];
>
respostasList[1] = RadioButtonList1.SelectedItem.Value;
>
>
Sorry my english and thanks again.
>
Grillo
>
"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
news:OgWpENvIIHA.4296@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>"Guilherme Grillo" <webdev@.rncomtotal.com.brwrote in message
>news:usThK6uIIHA.1212@.TK2MSFTNGP05.phx.gbl...
>>

Quote:

Originally Posted by

>>How can I populate an Array with the information of an Table in SQL?


>>
>http://www.google.co.uk/search?hl=e...Arraylist&meta=
>>
>>
>--
>Mark Rae
>ASP.NET MVP
>http://www.markrae.net


>
>

Populate Data in DropDown

Hello All

Please help me .. I am stuck in a problem regarding DropDownList..

I want to populate 101690 records in DropDown List .. Although i Know
that it is not feasible.
but there must be some alternative solution for this. Please suggest
me ..

with regards
Thank youWhat are you trying to achieve? Likely, you are not on the right track.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"TARUN" <tarun.sinha@.gmail.comwrote in message
news:1153289215.578826.38220@.s13g2000cwa.googlegro ups.com...

Quote:

Originally Posted by

Hello All
>
Please help me .. I am stuck in a problem regarding DropDownList..
>
I want to populate 101690 records in DropDown List .. Although i Know
that it is not feasible.
but there must be some alternative solution for this. Please suggest
me ..
>
with regards
Thank you
>

Saturday, March 24, 2012

Populate GridView with DataSet

I was using a DataView to bind records from a DB table to a DataGrid
using the following code:
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
dSet = New DataSet()
dView = New DataView
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
dgUsers.DataSource = dView
dgUsers.DataBind()
The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:
Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'
pointing to this line
gView = dSet.Tables("Users").DefaultView
How do I populate the GridView with the DataSet?Your DataSet and DataView variables stay the same. You will simply set
the DataSource of the GridView to your existing dView variable.
Using what you started with...

> sqlDapter.Fill(dSet, "Users")
> dView = dSet.Tables("Users").DefaultView

> dgUsers.DataSource = dView
> dgUsers.DataBind()
Assuming the GridView is named gvUsers, make the last two lines...
gvUsers.DataSource = dView
gvUsers.DataBind()
The DataGrid and GridView both take a DataView as the DataSource.
Brennan Stehling
http://brennan.offwhite.net/blog/
rn5a@.rediffmail.com wrote:
> I was using a DataView to bind records from a DB table to a DataGrid
> using the following code:
> Dim sqlDapter As SqlDataAdapter
> Dim dSet As DataSet
> Dim dView As DataView
> sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
> dSet = New DataSet()
> dView = New DataView
> sqlDapter.Fill(dSet, "Users")
> dView = dSet.Tables("Users").DefaultView
> dgUsers.DataSource = dView
> dgUsers.DataBind()
> The above works fine but I did like to bind the DataGrid to a GridView
> instead of a DataView as the above code shows. What I did is deleted
> the DataView from the above code & added a GridView i.e. all the
> instances of the DataView were replaced with GridView i.e. changed the
> variable name 'dView' to 'gView' but I get this error:
> Value of type 'System.Data.DataView' cannot be converted to
> 'System.Web.UI.WebControls.GridView'
> pointing to this line
> gView = dSet.Tables("Users").DefaultView
> How do I populate the GridView with the DataSet?

Populate GridView with DataSet

I was using a DataView to bind records from a DB table to a DataGrid
using the following code:

Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView

sqlDapter = New SqlDataAdapter(strSQL, sqlConn)

dSet = New DataSet()
dView = New DataView

sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView

dgUsers.DataSource = dView
dgUsers.DataBind()

The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:

Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'

pointing to this line

gView = dSet.Tables("Users").DefaultView

How do I populate the GridView with the DataSet?Your DataSet and DataView variables stay the same. You will simply set
the DataSource of the GridView to your existing dView variable.

Using what you started with...

Quote:

Originally Posted by

sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView


Quote:

Originally Posted by

dgUsers.DataSource = dView
dgUsers.DataBind()


Assuming the GridView is named gvUsers, make the last two lines...

gvUsers.DataSource = dView
gvUsers.DataBind()

The DataGrid and GridView both take a DataView as the DataSource.

Brennan Stehling
http://brennan.offwhite.net/blog/
rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

I was using a DataView to bind records from a DB table to a DataGrid
using the following code:
>
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
>
sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
>
dSet = New DataSet()
dView = New DataView
>
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
>
dgUsers.DataSource = dView
dgUsers.DataBind()
>
The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:
>
Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'
>
pointing to this line
>
gView = dSet.Tables("Users").DefaultView
>
How do I populate the GridView with the DataSet?

Wednesday, March 21, 2012

Populate TextBox With DB Records

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:
Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader
sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
Try
With sqlCmd
.Parameters.Add("@dotnet.itags.org.UserID", SqlDbType.Int).Value =
UserID
End With
sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try
Return sqlReader
End Function
End Class
End Namespace
Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.
This is the simple stored procedure:
CREATE PROCEDURE NETGetAddress
@dotnet.itags.org.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @dotnet.itags.org.UserID
The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
'here comes the other properties
Finally, this is the ASPX page:
<%@dotnet.itags.org. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@dotnet.itags.org. Import Namespace="NConnect" %>
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>
<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>
The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx
'retrieving the UserID by calling another function
nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)
sqlReader = boCart.GetAddress(iUserID)
Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>
But the above generates this error:
Invalid attempt to read when no data is present.
pointing to
nAddress.Address = sqlReader.GetString(1)
What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?
Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?
rn5a@.rediffmail.com wrote:
> This function in a VB class file takes UserID as a parameter & returns
> a SqlDataReader to the calling function which exists in a ASPX page:
> Namespace NConnect
> Public Class Cart
> Private sqlConn As New SqlConnection("....")
> Public Function GetAddress(ByVal UserID As Integer) As
> SqlDataReader
> Dim sqlCmd As SqlCommand
> Dim sqlReader As SqlDataReader
> sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
> sqlCmd.CommandType = CommandType.StoredProcedure
> Try
> With sqlCmd
> .Parameters.Add("@.UserID", SqlDbType.Int).Value =
> UserID
> End With
> sqlConn.Open()
> sqlReader = sqlCmd.ExecuteReader
> Catch ex As Exception
> Throw ex
> End Try
> Return sqlReader
> End Function
> End Class
> End Namespace
> Using vbc, I successfully compiled the above class file into a DLL
> named NConnect.dll.
> This is the simple stored procedure:
> CREATE PROCEDURE NETGetAddress
> @.UserID integer
> AS
> SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
> UserID = @.UserID
> The ASPX page uses a user control named 'Address.ascx' which has 5
> TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
> am using the Get & Set statement for creating a property for each of
> the TextBoxes like this:
> Public Property Address() As String
> Get
> Address = txtAddress.Text
> End Get
> Set(ByVal value As String)
> txtAddress.Text = value
> End Set
> End Property
> 'here comes the other properties
> Finally, this is the ASPX page:
> <%@. Register TagPrefix="NETConnect" TagName="Address"
> src="http://pics.10026.com/?src=NETAddress.ascx" %>
> <%@. Import Namespace="NConnect" %>
> <%@. Import Namespace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <script runat="server">
> Sub Page_Load(....)
> Dim boCart As Cart
> Dim iUserID As Integer
> Dim sqlReader As SqlDataReader
> 'retrieving the UserID by calling another function
> sqlReader = boCart.GetAddress(iUserID)
> End Sub
> </script>
> <form runat="server">
> <NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
> </form>
> The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
> TextBoxes with the records that the stored procedure retrieves for a
> particular UserID?
Well...the mistake I was making was I wasn't looping through the
SqlDataReader using the Read method of the SqlDataReader...
While(sqlReader.Read)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End While
rn5a@.rediffmail.com wrote:
> OK....this is what I tried in the ASPX page (this ASPX page is named
> NETAddress.aspx):
> <%@. Register TagPrefix="NETConnect" TagName="Address"
> src="http://pics.10026.com/?src=NETAddress.ascx" %>
> <%@. Import Namespace="NConnect" %>
> <%@. Import Namespace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <script runat="server">
> Sub Page_Load(....)
> Dim boCart As Cart
> Dim iUserID As Integer
> Dim sqlReader As SqlDataReader
> Dim nAddress As netaddress_ascx
> 'retrieving the UserID by calling another function
> nAddress = Page.LoadControl("NETAddress.ascx")
> nAddress.ID = "ncBilling"
> pnlAddress.Controls.Add(nAddress)
> sqlReader = boCart.GetAddress(iUserID)
> Response.Write("Field Count: " & sqlReader.FieldCount)
> nAddress.Address = sqlReader.GetString(1)
> nAddress.City = sqlReader.GetString(2)
> nAddress.StateName = sqlReader.GetString(3)
> nAddress.Country = sqlReader.GetString(4)
> nAddress.Zip = sqlReader.GetString(5)
> End Sub
> </script>
> <form runat="server">
> <asp:Panel ID="pnlAddress" runat="server"/>
> </form>
> But the above generates this error:
> Invalid attempt to read when no data is present.
> pointing to
> nAddress.Address = sqlReader.GetString(1)
> What's causing the error? Note the Response.Write(sqlReader.FieldCount)
> line. If I comment out all the GetString lines after this line, then
> sqlReader.FieldCount correctly displays the field count as 6. So how
> come sqlReader.GetString(1) has no data?
> Moreover if I bind the data to a DataList, then also the DataList
> renders all the records corresponding to the UserID; so where am I
> going wrong?
>
> rn5a@.rediffmail.com wrote:

Populate TextBox With DB Records

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:

Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader

sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure

Try
With sqlCmd
.Parameters.Add("@dotnet.itags.org.UserID", SqlDbType.Int).Value =
UserID
End With

sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try

Return sqlReader
End Function
End Class
End Namespace

Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.

This is the simple stored procedure:

CREATE PROCEDURE NETGetAddress
@dotnet.itags.org.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @dotnet.itags.org.UserID

The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:

Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property

'here comes the other properties

Finally, this is the ASPX page:

<%@dotnet.itags.org. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@dotnet.itags.org. Import Namespace="NConnect" %>
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader

'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>

<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>

The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):

<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx

'retrieving the UserID by calling another function

nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)

sqlReader = boCart.GetAddress(iUserID)

Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>

But the above generates this error:

Invalid attempt to read when no data is present.

pointing to

nAddress.Address = sqlReader.GetString(1)

What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?

Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?

rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:
>
Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader
>
sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
>
Try
With sqlCmd
.Parameters.Add("@.UserID", SqlDbType.Int).Value =
UserID
End With
>
sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try
>
Return sqlReader
End Function
End Class
End Namespace
>
Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.
>
This is the simple stored procedure:
>
CREATE PROCEDURE NETGetAddress
@.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @.UserID
>
The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:
>
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
>
'here comes the other properties
>
Finally, this is the ASPX page:
>
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
>
'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>
>
<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>
>
The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?


Well...the mistake I was making was I wasn't looping through the
SqlDataReader using the Read method of the SqlDataReader...

While(sqlReader.Read)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End While

rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):
>
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx
>
'retrieving the UserID by calling another function
>
nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)
>
sqlReader = boCart.GetAddress(iUserID)
>
Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>
>
But the above generates this error:
>
Invalid attempt to read when no data is present.
>
pointing to
>
nAddress.Address = sqlReader.GetString(1)
>
What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?
>
Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?
>
>
rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:

Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader

sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure

Try
With sqlCmd
.Parameters.Add("@.UserID", SqlDbType.Int).Value =
UserID
End With

sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try

Return sqlReader
End Function
End Class
End Namespace

Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.

This is the simple stored procedure:

CREATE PROCEDURE NETGetAddress
@.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @.UserID

The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:

Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property

'here comes the other properties

Finally, this is the ASPX page:

<%@. Register TagPrefix="NETConnect" TagName="Address"
src="http://pics.10026.com/?src=NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader

'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>

<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>

The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?

Populating a datagrid from two separate data sources

Hi all,

I have an interesting situation. I have a datagrid I'm currently populating
using a dataset but now I need to introduce some extra records into this.
I'm unsure of which method to use. Is it possible for me to populate (fill)
a dataset from another dataset and at the same time, make sure there are no
duplicates?

Regards
John.John,

Check out the Merge method of the DataSet class. It might just be what
you're after.

--
Carsten Thomsen
Enterprise Development with Visual Studio .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"John" <a@.b.com> wrote in message
news:uITE8tpVDHA.384@.TK2MSFTNGP12.phx.gbl...
> Hi all,
> I have an interesting situation. I have a datagrid I'm currently
populating
> using a dataset but now I need to introduce some extra records into this.
> I'm unsure of which method to use. Is it possible for me to populate
(fill)
> a dataset from another dataset and at the same time, make sure there are
no
> duplicates?
> Regards
> John.