Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Thursday, March 29, 2012

Popping opening a mail client and pass a subject parameter...

Hi:

Is there a way to pop open a mail client and pass in a text string for the
subject and possibly other parts of a standard mail message? The "mailto:"
attribute of hyplerlink leaves these blank.

Thanks,
Charlieread up on the mailto: link, it does have a &Subject='text'&Body='text'
attribute IIRC

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com

"Charlie@.CBFC" <charle1@.comcast.net> wrote in message
news:eSlBhiR4DHA.1752@.tk2msftngp13.phx.gbl...
> Hi:
> Is there a way to pop open a mail client and pass in a text string for the
> subject and possibly other parts of a standard mail message? The
"mailto:"
> attribute of hyplerlink leaves these blank.
> Thanks,
> Charlie

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 data grid with a stored procudure w/parameters

All,

I'm trying to populate a datagrid with a data adapter that uses a stored
procedure with a parameter. I get the below error when I run my code
(as seen below). Any hints?

If I delete the .value = "Business Acumen" at the end of the add
parameters statement & put the below code on a different row, the error
goes away, but I get back an empty dataset.

Me.cmdUYP.Parameters("@dotnet.itags.org.web_competency_name").Value = "Business Acumen"

Error Msg:
The SqlParameterCollection only accepts non-null SqlParameter type
objects, not Boolean objects.

My Code:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Imports System.Text

Public Class UYP_Class
Inherits System.Web.UI.Page
Protected WithEvents btnFLMClose As System.Web.UI.WebControls.Button
Dim previousCat As String
Dim previousComp As String
Protected WithEvents linkIntelU As
System.Web.UI.WebControls.HyperLink
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents btnClose As System.Web.UI.WebControls.Button
Protected WithEvents lnkIntelLibrary As
System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkBuyOnline As
System.Web.UI.WebControls.HyperLink
Protected WithEvents conUYP As System.Data.SqlClient.SqlConnection
Protected WithEvents lblError As System.Web.UI.WebControls.Label
Protected WithEvents daUYP As System.Data.SqlClient.SqlDataAdapter
Protected WithEvents cmdUYP As System.Data.SqlClient.SqlCommand
Protected WithEvents DsUYP1 As FDO.dsUYP
Protected WithEvents lnkAllCurric As
System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkHelp As System.Web.UI.WebControls.HyperLink
Protected WithEvents dgUYP As System.Web.UI.WebControls.DataGrid
Protected WithEvents btnExportExcel As
System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.conUYP = New System.Data.SqlClient.SqlConnection()
Me.daUYP = New System.Data.SqlClient.SqlDataAdapter()
Me.cmdUYP = New System.Data.SqlClient.SqlCommand()
Me.DsUYP1 = New FDO.dsUYP()
CType(Me.DsUYP1,
System.ComponentModel.ISupportInitialize).BeginIni t()
'
'conUYP
'
Me.conUYP.ConnectionString = "data source=OREA2SQL017;initial
catalog=Fin_Trng_DB;password=abcd$1234;persist se" & _
"curity info=True;user id=FinTrngUserGrp"
'
'daUYP
'
Me.daUYP.SelectCommand = Me.cmdUYP
'
'cmdUYP
'
Me.cmdUYP.CommandText = "dbo.[prc_uyp_curriculum]"
Me.cmdUYP.CommandType = System.Data.CommandType.StoredProcedure
Me.cmdUYP.Connection = Me.conUYP
Me.cmdUYP.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.web_competency_name",
System.Data.SqlDbType.NVarChar, 50).Value = "Business Acumen")

'
'DsUYP1
'
Me.DsUYP1.DataSetName = "dsUYP"
Me.DsUYP1.Locale = New System.Globalization.CultureInfo("en-US")
Me.DsUYP1.Namespace = "http://www.tempuri.org/dsUYP.xsd"
CType(Me.DsUYP1,
System.ComponentModel.ISupportInitialize).EndInit( )

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Try
'Me.cmdUYP.Parameters("web_competency_name").Value =
"Business Acumen"
daUYP.Fill(DsUYP1, "prc_uyp_curriculum")
If Not IsPostBack Then
dgUYP.DataSource =
DsUYP1._dbo_prc_uyp_curriculum.DefaultView()
dgUYP.DataBind()
End If
End Sub
End Class

Machelle Chandler
Intel Corporation
Beginning .NET developer
Thanks in advance for the help!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi Machelle. Try changing this
Me.cmdUYP.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@.web_competency_name",
System.Data.SqlDbType.NVarChar, 50).Value = "Business Acumen")

for
Me.cmdUYP.Parameters.Add("@.web_competency_name",
System.Data.SqlDbType.NVarChar, 50).Value = "Business Acumen";

"Machelle Chandler" <machelle.a.chandler@.intel.com> wrote in message
news:#fF2buClDHA.2232@.TK2MSFTNGP09.phx.gbl...
> All,
> I'm trying to populate a datagrid with a data adapter that uses a stored
> procedure with a parameter. I get the below error when I run my code
> (as seen below). Any hints?
> If I delete the .value = "Business Acumen" at the end of the add
> parameters statement & put the below code on a different row, the error
> goes away, but I get back an empty dataset.
> Me.cmdUYP.Parameters("@.web_competency_name").Value = "Business Acumen"
> Error Msg:
> The SqlParameterCollection only accepts non-null SqlParameter type
> objects, not Boolean objects.
>
> My Code:
> Imports System
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Text.RegularExpressions
> Imports System.Text
>
> Public Class UYP_Class
> Inherits System.Web.UI.Page
> Protected WithEvents btnFLMClose As System.Web.UI.WebControls.Button
> Dim previousCat As String
> Dim previousComp As String
> Protected WithEvents linkIntelU As
> System.Web.UI.WebControls.HyperLink
> Protected WithEvents Image1 As System.Web.UI.WebControls.Image
> Protected WithEvents btnClose As System.Web.UI.WebControls.Button
> Protected WithEvents lnkIntelLibrary As
> System.Web.UI.WebControls.HyperLink
> Protected WithEvents lnkBuyOnline As
> System.Web.UI.WebControls.HyperLink
> Protected WithEvents conUYP As System.Data.SqlClient.SqlConnection
> Protected WithEvents lblError As System.Web.UI.WebControls.Label
> Protected WithEvents daUYP As System.Data.SqlClient.SqlDataAdapter
> Protected WithEvents cmdUYP As System.Data.SqlClient.SqlCommand
> Protected WithEvents DsUYP1 As FDO.dsUYP
> Protected WithEvents lnkAllCurric As
> System.Web.UI.WebControls.HyperLink
> Protected WithEvents lnkHelp As System.Web.UI.WebControls.HyperLink
> Protected WithEvents dgUYP As System.Web.UI.WebControls.DataGrid
> Protected WithEvents btnExportExcel As
> System.Web.UI.WebControls.Button
> #Region " Web Form Designer Generated Code "
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.conUYP = New System.Data.SqlClient.SqlConnection()
> Me.daUYP = New System.Data.SqlClient.SqlDataAdapter()
> Me.cmdUYP = New System.Data.SqlClient.SqlCommand()
> Me.DsUYP1 = New FDO.dsUYP()
> CType(Me.DsUYP1,
> System.ComponentModel.ISupportInitialize).BeginIni t()
> '
> 'conUYP
> '
> Me.conUYP.ConnectionString = "data source=OREA2SQL017;initial
> catalog=Fin_Trng_DB;password=abcd$1234;persist se" & _
> "curity info=True;user id=FinTrngUserGrp"
> '
> 'daUYP
> '
> Me.daUYP.SelectCommand = Me.cmdUYP
> '
> 'cmdUYP
> '
> Me.cmdUYP.CommandText = "dbo.[prc_uyp_curriculum]"
> Me.cmdUYP.CommandType = System.Data.CommandType.StoredProcedure
> Me.cmdUYP.Connection = Me.conUYP
> Me.cmdUYP.Parameters.Add(New
> System.Data.SqlClient.SqlParameter("@.web_competency_name",
> System.Data.SqlDbType.NVarChar, 50).Value = "Business Acumen")
> '
> 'DsUYP1
> '
> Me.DsUYP1.DataSetName = "dsUYP"
> Me.DsUYP1.Locale = New System.Globalization.CultureInfo("en-US")
> Me.DsUYP1.Namespace = "http://www.tempuri.org/dsUYP.xsd"
> CType(Me.DsUYP1,
> System.ComponentModel.ISupportInitialize).EndInit( )
> End Sub
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
> #End Region
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> Try
> 'Me.cmdUYP.Parameters("web_competency_name").Value =
> "Business Acumen"
> daUYP.Fill(DsUYP1, "prc_uyp_curriculum")
> If Not IsPostBack Then
> dgUYP.DataSource =
> DsUYP1._dbo_prc_uyp_curriculum.DefaultView()
> dgUYP.DataBind()
> End If
> End Sub
> End Class
> Machelle Chandler
> Intel Corporation
> Beginning .NET developer
> Thanks in advance for the help!
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

populating a datagrid from a parameterized procedure during page load

I have a datagrid control on my page populated from a parameterized stored procedure. The parameter comes from a label control on my page as seen below. I cannot get the grid to populate. Any suggestions?

Dim LocalIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If LocalIP =""Then
LocalIP = Request.ServerVariables("REMOTE_ADDR")
EndIf
Label1.Text = LocalIP

TIA <JP>

Hi paskettj,

first check if Label1.text has been assigned to the correct value(mean, what's the value of " LocalIP" ? you can use debug, or response.write to monitor it);

secondly,check if your sotred procedure has returned the correct data;

and the third, pls check if you have use datagrid correctly. To get your datagrid control populated with corresponding data,First, you need to set the correct DataSource or DataSourceID, then call the Databind() method. It doesn't matter where you get your data from(whether it's from a table,backend database, from parameterized stored procedure...etc).

for more detailed information, i suggest you reading some material by clicking the following links:

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.basedatalist.datasource(VS.71).aspx (the sample within this page should help u use datagrid)

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.aspx (to a overview of datagird class)

hope my suggestion helps :)