Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Saturday, March 31, 2012

system.exception.handles : Object Must Inconvertible

i would like to execute an stored procedure command from asp.net.
i think all of my syntax is generaly true. but when i test it in ie browser. an error occured and
show the messages :
system.exception.handles : Object Must Inconvertible
anyone help me....
thank u very much.Crying [:'(]

Can you post the code that is causing the error?

Note: Please post the appropriate section(s), not the whole page.

System.InvalidCastException

Hope someone can help. I am trying to get a submit button working and
getting this error now System.InvalidCastException: Object must implement
IConvertible. This is showing up on the ExecuteNonQuery line. Below is the
code that I have in my Page_load. I also have no idea of what code I would
use in the Submit_Click event to get the insert to work. Any help would be
appreciated
OleDbConnection conn = new
OleDbConnection("Provider=OraOLEDB.Oracle.1;Persist Security
Info=False;"+"User ID=conference;Password=conf00;Data
Source=ntdrp001.world;");
OleDbCommand command = new OleDbCommand("CONF-REQUEST_INSERT", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("DropDownList1", OleDbType.VarChar).Value =
DropDownList1;
command.Parameters.Add("DropDownList2", OleDbType.VarChar).Value =
DropDownList2;
command.Parameters.Add("txtEStartDate", OleDbType.Date).Value =
txtEStartDate;
command.Parameters.Add("txtEEndDate", OleDbType.Date).Value = txtEEndDate;
command.Parameters.Add("txtEStartTime", OleDbType.Numeric).Value =
txtEStartTime;
command.Parameters.Add("txtEEndTime", OleDbType.Numeric).Value =
txtEEndTime;
command.Parameters.Add("txtEventName", OleDbType.VarChar).Value =
txtEventName;
command.Parameters.Add("txtEventSize", OleDbType.Numeric).Value =
txtEventSize;
command.Parameters.Add("txtSStartDate", OleDbType.Date).Value =
txtSStartDate;
command.Parameters.Add("txtSStartTime", OleDbType.Numeric).Value =
txtSStartTime;
command.Parameters.Add("txtEventDescription", OleDbType.VarChar).Value =
txtEventDescription;
command.Parameters.Add("txtSpecialRequirements", OleDbType.VarChar).Value =
txtSpecialRequirements;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();Hi, Brian,
The reason is that you directly use the web control objects for the value as
signments. You have to use their properties. like:
command.Parameters.Add("DropDownList1", OleDbType.VarChar).Value = DropDownL
ist1.SelectedItem.Value;
command.Parameters.Add("txtEStartDate", OleDbType.Date).Value = txtEStartDat
e.Text;
Bin Song, MCP

System.InvalidCastException: Specified cast is not valid

I keep geting the exception:

System.InvalidCastException: Specified cast is not valid.

I get this when I try to pass a DataRow into an object method. The line that
causes this error is:

policy.SetValues(dr);

Here is part of the class that contains the method that I want to call:

using System;
using System.Data;
using System.Collections;

namespace IDUL.Policies
{

/// <summary>
/// </summary>
public class Policy
{
private int _qid;
private int _cid;
private string _policy_number;
private string _inception_date;
private string _expiry_date;
private float _raw_premium;
private float _policy_fee;
private float _admin_fee;
private float _ipt;
private float _total_premium;
private bool _is_renewal;
private string _operator;
private string _date_quoted;
private bool _on_cover;
private string _on_cover_date;
private string _on_cover_operator;

/// <summary>
/// </summary>
public Policy()
{
Trace.Constructor("Policy()");
}

/// <summary>
/// </summary>
public Policy(DataRow dr)
{
Trace.EnterConst("Policy(dr)");

if (dr != null)
{
SetValues(dr);
}

Trace.LeaveConst("Policy(dr)");
}

public void SetValues(DataRow dr)
{
_qid = (int)dr["qid"];
_cid = (int)dr["cid"];
_policy_number = dr["policy_number"].ToString();
_inception_date = dr["inception_date"].ToString();
_expiry_date = dr["expiry_date"].ToString();
_raw_premium = (float)dr["raw_premium"];
_policy_fee = (float)dr["policy_fee"];
_admin_fee = (float)dr["admin_fee"];
_ipt = (float)dr["ipt"];
_total_premium = (float)dr["total_premium"];
_is_renewal = (bool)dr["is_renewal"];
_operator = dr["operator"].ToString();
_date_quoted = dr["date_quoted"].ToString();
_on_cover = (bool)dr["on_cover"];
_on_cover_date = dr["on_cover_date"].ToString();
_on_cover_operator = dr["on_cover_operator"].ToString();
}
}

The code that instantiates the class and calls the method is in here:

foreach (DataTable dt in dsPolicies.Tables)
{
foreach (DataRow dr in dt.Rows)
{
Policy policy = new Policy();

policy.SetValues(dr);

arrPolicies.Add(policy);
}
}

Any ideas what is causing this exception?Floela <floela@.benjamin.com> wrote:
> I keep geting the exception:
> System.InvalidCastException: Specified cast is not valid.
>
> I get this when I try to pass a DataRow into an object method. The line that
> causes this error is:
> policy.SetValues(dr);

I'm sure that's one part of the stack, but I don't think that's going
to be the actual direct causal line. I suspect it's somewhere within
SetValues itself. Have you tried stepping through SetValues to see
where the exception is thrown?

--
Jon Skeet - <skeet@.pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

> I get this when I try to pass a DataRow into an object method. The line
that
> causes this error is:
> policy.SetValues(dr);
Inside SetValues there are many cast without checking,
i wonder if they are all safe ?

> public void SetValues(DataRow dr)
> {
> _qid = (int)dr["qid"];
> _cid = (int)dr["cid"];
> _raw_premium = (float)dr["raw_premium"];
> _policy_fee = (float)dr["policy_fee"];
> _admin_fee = (float)dr["admin_fee"];
> _ipt = (float)dr["ipt"];
> _total_premium = (float)dr["total_premium"];
> _is_renewal = (bool)dr["is_renewal"];
> _on_cover = (bool)dr["on_cover"];
> }
Floela <floela@.benjamin.com> wrote:
> > I'm sure that's one part of the stack, but I don't think that's going
> > to be the actual direct causal line. I suspect it's somewhere within
> > SetValues itself.
> SetValues is pretty simple - just assigning the values from the DataRow to
> private variables within the class (see my original post). There's nothing
> glaring as to where the problem could be within this method.

Yes there is - you've got lots of casts in SetValues. I'm sure it'll be
one of those which is failing.

> > Have you tried stepping through SetValues to see
> > where the exception is thrown?
> No I haven't, as I'm actually coding the application using TextPad, not
> VS.NET.

Ah. That's a pain. Can you print out a stack trace to show exactly
where it's failing?

--
Jon Skeet - <skeet@.pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

System.InvalidCastException: Specified cast is not valid.

Hi
I get the this error when i run my code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.DataGrid1.DataSource= this.DataSource();
this.DataGrid1.DataBind();
}
private ICollection DataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
for (int i=0;i<10;i++)
{
DataRow dr = dt.NewRow();
if (i%2==0)
{
dr[0]=1;
}
else
{
dr[0]=0;
}
dt.Rows.Add(dr);
}
DataView dv;
dv = new DataView(dt);
return dv;
}
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
int i = e.Item.ItemIndex;
if(i==0)
{
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
}
}
page:
one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.
It should be pretty easy to step through your code and debug though...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>
>

System.InvalidCastException: Specified cast is not valid.

Hi

I get the this error when i run my code:

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

this.DataGrid1.DataSource= this.DataSource();

this.DataGrid1.DataBind();

}

private ICollection DataSource()

{

DataTable dt = new DataTable();

dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));

for (int i=0;i<10;i++)

{

DataRow dr = dt.NewRow();

if (i%2==0)

{

dr[0]=1;

}

else

{

dr[0]=0;

}

dt.Rows.Add(dr);

}

DataView dv;

dv = new DataView(dt);

return dv;

}

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

int i = e.Item.ItemIndex;

if(i==0)

{

((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";

}

}

page:

one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";

First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.

It should be pretty easy to step through your code and debug though...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>

Wednesday, March 28, 2012

System.io.File

When using the File object how do you now whether the path you are putting, is the path of a file on the server or the path of a file on the client machine.

I want to transfer a file from the client machine to the server, does anyone know if the File object is suited for this?I guess the real question there is where did you get the path from.

If the path came from the Posted File - then it is most likely the file path / name from the client not and is not valid for saving on the server
What do you mean when you say where the path came from, what if i hard code a file path to be e.g c:/intepub/newfolder/file.txt

If i put that path into a file object, would that look at c: on the server or client?
It's always a Path on your server or another machine in your network, over which you (or rather the ASPNET worker process or some other user you let the worker process impersonate) have rights to access.

The only time you handle a client path, is when someone has uploaded a file to your server.
Ok, but thats what i want to do using asp.net, i want to allow users to upload a file from their machine to the server. I have done this successfully using Java, but wanted to know if its possible using .net
It's extremely easy using .Net. One line of code will suffice in this very simple scenario:


<%@. Page Language="VB" %>
<%@. import Namespace="System.IO" %>
<script runat="server">
Sub Button_Click( obj As Object, evnt As EventArgs )
inpFileName.PostedFile.SaveAs( Server.MapPath("") & Path.GetFileName(inpFileName.PostedFile.FileName) )
End Sub
</script>
<html>
<head>
<title>Upload file</title>
</head>
<body>
<form enctype="multipart/form-data" runat="Server">
<input id="inpFileName" type="file" runat="Server" /><br>
<asp:Button id="btnFileUp" onclick="Button_Click" Runat="Server" Text="Upload file" /></form>
</body>
</html>

This will save an uploaded file to the root of your web application. Remember to grant rights to write to the physical folder for the ASPNET account. By default the max file size to be uploaded using .Net is set to 4 mb (4096 kb). If you need to up this size, you set it in your application's Web.config file using:

<httpRuntime maxRequestLength="<size in kb you wish to allow>" />

Thanks very much

System.IO.Ports.SerialPort

is there a way to embed the System.IO.Ports.SerialPort object in my html . s
o
that the client can access to a device connected to his SerialCOM ?
i tried to wrap the System.IO.Ports.SerialPort in my own component and then
put it in <object> but it doesnt seem to work, any suggestions?I doubt the security sandbox of the user's browser would allow such a thing.
You'll probably need a thick client such as an ActiveX control or Windows
Forms application.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
> is there a way to embed the System.IO.Ports.SerialPort object in my html .
> so
> that the client can access to a device connected to his SerialCOM ?
> i tried to wrap the System.IO.Ports.SerialPort in my own component and
> then
> put it in <object> but it doesnt seem to work, any suggestions?
You can run .NET components on the client side browser provided that your
client has the .NET framework installed and willing to allow you to do so.
SA
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>I doubt the security sandbox of the user's browser would allow such a
>thing.
> You'll probably need a thick client such as an ActiveX control or Windows
> Forms application.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
>
but the standard .net seetings would not allow the component to access
serial ports. the users will have to authorize your component to do this
using the caspol.exe utility.
-- bruce (sqlwork.com)
"MSDN" <sql_agentman@.hotmail.com> wrote in message
news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> You can run .NET components on the client side browser provided that your
> client has the .NET framework installed and willing to allow you to do so.
> SA
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>
Yes some security has to be set properly. I would use this in Intranet or
Wide-Intranet-Corp situations.
SA
"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com> wrote
in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
> but the standard .net seetings would not allow the component to access
> serial ports. the users will have to authorize your component to do this
> using the caspol.exe utility.
> -- bruce (sqlwork.com)
> "MSDN" <sql_agentman@.hotmail.com> wrote in message
> news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>
so what do i need to write inside my <object> tag? what is the classid for
SerialPort?
"MSDN" wrote:

> Yes some security has to be set properly. I would use this in Intranet or
> Wide-Intranet-Corp situations.
> SA
>
> "bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com> wro
te
> in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
>
>
Read this that might help you out.
http://msdn.microsoft.com/msdnmag/i...02/01/UserCtrl/
SA
"Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
news:7C59DB6A-82AE-41B6-ACCB-936BC5723A66@.microsoft.com...
> so what do i need to write inside my <object> tag? what is the classid for
> SerialPort?
> "MSDN" wrote:
>
i read the article and followed all the steps but the it doesnt work, im
using VS 2005 and the artitcle was in 2002 so maybe the project upgrade
ruined something. any way i still cant create the control i need, any
suggestions?
"MSDN" wrote:

> Read this that might help you out.
> http://msdn.microsoft.com/msdnmag/i...02/01/UserCtrl/
> SA
> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> news:7C59DB6A-82AE-41B6-ACCB-936BC5723A66@.microsoft.com...
>
>

System.IO.Ports.SerialPort

is there a way to embed the System.IO.Ports.SerialPort object in my html . so
that the client can access to a device connected to his SerialCOM ?

i tried to wrap the System.IO.Ports.SerialPort in my own component and then
put it in <object> but it doesnt seem to work, any suggestions?I doubt the security sandbox of the user's browser would allow such a thing.
You'll probably need a thick client such as an ActiveX control or Windows
Forms application.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
> is there a way to embed the System.IO.Ports.SerialPort object in my html .
> so
> that the client can access to a device connected to his SerialCOM ?
> i tried to wrap the System.IO.Ports.SerialPort in my own component and
> then
> put it in <object> but it doesnt seem to work, any suggestions?
You can run .NET components on the client side browser provided that your
client has the .NET framework installed and willing to allow you to do so.

SA

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>I doubt the security sandbox of the user's browser would allow such a
>thing.
> You'll probably need a thick client such as an ActiveX control or Windows
> Forms application.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
>> is there a way to embed the System.IO.Ports.SerialPort object in my html
>> . so
>> that the client can access to a device connected to his SerialCOM ?
>>
>> i tried to wrap the System.IO.Ports.SerialPort in my own component and
>> then
>> put it in <object> but it doesnt seem to work, any suggestions?
but the standard .net seetings would not allow the component to access
serial ports. the users will have to authorize your component to do this
using the caspol.exe utility.

-- bruce (sqlwork.com)

"MSDN" <sql_agentman@.hotmail.com> wrote in message
news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> You can run .NET components on the client side browser provided that your
> client has the .NET framework installed and willing to allow you to do so.
> SA
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>>I doubt the security sandbox of the user's browser would allow such a
>>thing.
>> You'll probably need a thick client such as an ActiveX control or Windows
>> Forms application.
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
>> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
>>> is there a way to embed the System.IO.Ports.SerialPort object in my html
>>> . so
>>> that the client can access to a device connected to his SerialCOM ?
>>>
>>> i tried to wrap the System.IO.Ports.SerialPort in my own component and
>>> then
>>> put it in <object> but it doesnt seem to work, any suggestions?
>>
>>
Yes some security has to be set properly. I would use this in Intranet or
Wide-Intranet-Corp situations.

SA

"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com> wrote
in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
> but the standard .net seetings would not allow the component to access
> serial ports. the users will have to authorize your component to do this
> using the caspol.exe utility.
> -- bruce (sqlwork.com)
> "MSDN" <sql_agentman@.hotmail.com> wrote in message
> news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>>
>> You can run .NET components on the client side browser provided that your
>> client has the .NET framework installed and willing to allow you to do
>> so.
>>
>> SA
>>
>> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>>>I doubt the security sandbox of the user's browser would allow such a
>>>thing.
>>> You'll probably need a thick client such as an ActiveX control or
>>> Windows Forms application.
>>>
>>> --
>>> I hope this helps,
>>> Steve C. Orr, MCSD, MVP
>>> http://SteveOrr.net
>>>
>>>
>>> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
>>> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
>>>> is there a way to embed the System.IO.Ports.SerialPort object in my
>>>> html . so
>>>> that the client can access to a device connected to his SerialCOM ?
>>>>
>>>> i tried to wrap the System.IO.Ports.SerialPort in my own component and
>>>> then
>>>> put it in <object> but it doesnt seem to work, any suggestions?
>>>
>>>
>>
>>
so what do i need to write inside my <object> tag? what is the classid for
SerialPort?

"MSDN" wrote:

> Yes some security has to be set properly. I would use this in Intranet or
> Wide-Intranet-Corp situations.
> SA
>
> "bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com> wrote
> in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
> > but the standard .net seetings would not allow the component to access
> > serial ports. the users will have to authorize your component to do this
> > using the caspol.exe utility.
> > -- bruce (sqlwork.com)
> > "MSDN" <sql_agentman@.hotmail.com> wrote in message
> > news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> >>
> >> You can run .NET components on the client side browser provided that your
> >> client has the .NET framework installed and willing to allow you to do
> >> so.
> >>
> >> SA
> >>
> >> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> >> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> >>>I doubt the security sandbox of the user's browser would allow such a
> >>>thing.
> >>> You'll probably need a thick client such as an ActiveX control or
> >>> Windows Forms application.
> >>>
> >>> --
> >>> I hope this helps,
> >>> Steve C. Orr, MCSD, MVP
> >>> http://SteveOrr.net
> >>>
> >>>
> >>> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> >>> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
> >>>> is there a way to embed the System.IO.Ports.SerialPort object in my
> >>>> html . so
> >>>> that the client can access to a device connected to his SerialCOM ?
> >>>>
> >>>> i tried to wrap the System.IO.Ports.SerialPort in my own component and
> >>>> then
> >>>> put it in <object> but it doesnt seem to work, any suggestions?
> >>>
> >>>
> >>
> >>
>
Read this that might help you out.

http://msdn.microsoft.com/msdnmag/i...02/01/UserCtrl/

SA

"Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
news:7C59DB6A-82AE-41B6-ACCB-936BC5723A66@.microsoft.com...
> so what do i need to write inside my <object> tag? what is the classid for
> SerialPort?
> "MSDN" wrote:
>> Yes some security has to be set properly. I would use this in Intranet
>> or
>> Wide-Intranet-Corp situations.
>>
>> SA
>>
>>
>> "bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com>
>> wrote
>> in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
>> > but the standard .net seetings would not allow the component to access
>> > serial ports. the users will have to authorize your component to do
>> > this
>> > using the caspol.exe utility.
>>> > -- bruce (sqlwork.com)
>>> > "MSDN" <sql_agentman@.hotmail.com> wrote in message
>> > news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>> >>
>> >> You can run .NET components on the client side browser provided that
>> >> your
>> >> client has the .NET framework installed and willing to allow you to do
>> >> so.
>> >>
>> >> SA
>> >>
>> >> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>> >> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
>> >>>I doubt the security sandbox of the user's browser would allow such a
>> >>>thing.
>> >>> You'll probably need a thick client such as an ActiveX control or
>> >>> Windows Forms application.
>> >>>
>> >>> --
>> >>> I hope this helps,
>> >>> Steve C. Orr, MCSD, MVP
>> >>> http://SteveOrr.net
>> >>>
>> >>>
>> >>> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
>> >>> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
>> >>>> is there a way to embed the System.IO.Ports.SerialPort object in my
>> >>>> html . so
>> >>>> that the client can access to a device connected to his SerialCOM ?
>> >>>>
>> >>>> i tried to wrap the System.IO.Ports.SerialPort in my own component
>> >>>> and
>> >>>> then
>> >>>> put it in <object> but it doesnt seem to work, any suggestions?
>> >>>
>> >>>
>> >>
>> >>
>>>>
>>
>
i read the article and followed all the steps but the it doesnt work, im
using VS 2005 and the artitcle was in 2002 so maybe the project upgrade
ruined something. any way i still cant create the control i need, any
suggestions?

"MSDN" wrote:

> Read this that might help you out.
> http://msdn.microsoft.com/msdnmag/i...02/01/UserCtrl/
> SA
> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> news:7C59DB6A-82AE-41B6-ACCB-936BC5723A66@.microsoft.com...
> > so what do i need to write inside my <object> tag? what is the classid for
> > SerialPort?
> > "MSDN" wrote:
> >> Yes some security has to be set properly. I would use this in Intranet
> >> or
> >> Wide-Intranet-Corp situations.
> >>
> >> SA
> >>
> >>
> >> "bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com>
> >> wrote
> >> in message news:eWT40VRdGHA.4128@.TK2MSFTNGP05.phx.gbl...
> >> > but the standard .net seetings would not allow the component to access
> >> > serial ports. the users will have to authorize your component to do
> >> > this
> >> > using the caspol.exe utility.
> >> >> > -- bruce (sqlwork.com)
> >> >> > "MSDN" <sql_agentman@.hotmail.com> wrote in message
> >> > news:e4%2340ARdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> >> >>
> >> >> You can run .NET components on the client side browser provided that
> >> >> your
> >> >> client has the .NET framework installed and willing to allow you to do
> >> >> so.
> >> >>
> >> >> SA
> >> >>
> >> >> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> >> >> news:eK0s3eQdGHA.3888@.TK2MSFTNGP02.phx.gbl...
> >> >>>I doubt the security sandbox of the user's browser would allow such a
> >> >>>thing.
> >> >>> You'll probably need a thick client such as an ActiveX control or
> >> >>> Windows Forms application.
> >> >>>
> >> >>> --
> >> >>> I hope this helps,
> >> >>> Steve C. Orr, MCSD, MVP
> >> >>> http://SteveOrr.net
> >> >>>
> >> >>>
> >> >>> "Tamir.D" <Tamir.D@.discussions.microsoft.com> wrote in message
> >> >>> news:1F4238ED-0121-482A-9359-10B1F0593C8C@.microsoft.com...
> >> >>>> is there a way to embed the System.IO.Ports.SerialPort object in my
> >> >>>> html . so
> >> >>>> that the client can access to a device connected to his SerialCOM ?
> >> >>>>
> >> >>>> i tried to wrap the System.IO.Ports.SerialPort in my own component
> >> >>>> and
> >> >>>> then
> >> >>>> put it in <object> but it doesnt seem to work, any suggestions?
> >> >>>
> >> >>>
> >> >>
> >> >>
> >> >> >>
> >>
> >>
>

Monday, March 26, 2012

System.Net.HttpWebRequest with HTTPS

I am using the System.Net.HttpWebRequest object to POST data to an HTTPS web
page.

Other than prefixing the URL with "HTTPS://", do I need to do anything in my
code to indicate that this is SSL?

Here is my code:
// Create Web Request
string url = "https://something.net/something.dll";

HttpWebRequest oHttp =
(HttpWebRequest) WebRequest.Create(url);

// Post form variables
string params = "x_Version=" + version
+ "&x_DelimData=" + delimData
+ "&x_Login=" + login
+ "&x_Password=" + password
+ "&x_Amount=" + amount
+ "&x_Card_Num=" + cardNumber
+ "&x_Exp_Date=" + expirationDate
+ "&x_Type=" + type;
oHttp.Method="POST";
byte [] postBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(pa rams);
oHttp.ContentLength = postBuffer.Length;
Stream postData = oHttp.GetRequestStream();
postData.Write(postBuffer,0,postBuffer.Length);
postData.Close();

// Get results
HttpWebResponse myResponse = (HttpWebResponse) oHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(myResponse.GetResponseStream(), enc);
string retHtml = loResponseStream.ReadToEnd();
myResponse.Close();
loResponseStream.Close();

messages = retHtml;"dgiard" spoke:

> I am using the System.Net.HttpWebRequest object to POST data to an
> HTTPS web page.
> Other than prefixing the URL with "HTTPS://", do I need to do
> anything in my code to indicate that this is SSL?

Check out if the framework's default certificate policy (URL below)
works for you. If not, you need to implement your own. But that should
be it.

http://msdn.microsoft.com/library/d...rl=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp

Cheers,
--
Joerg Jooss
joerg.jooss@.gmx.net
Thanks, Joerg.

"Joerg Jooss" <joerg.jooss@.gmx.net> wrote in message
news:OfG1RIqTDHA.3132@.tk2msftngp13.phx.gbl...
> "dgiard" spoke:
> > I am using the System.Net.HttpWebRequest object to POST data to an
> > HTTPS web page.
> > Other than prefixing the URL with "HTTPS://", do I need to do
> > anything in my code to indicate that this is SSL?
> Check out if the framework's default certificate policy (URL below)
> works for you. If not, you need to implement your own. But that should
> be it.
> http://msdn.microsoft.com/library/d...rl=/library/en-
> us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
> ic.asp
> Cheers,
> --
> Joerg Jooss
> joerg.jooss@.gmx.net

Thursday, March 22, 2012

System.NullReferenceException on TextBox object...

Hello,
I am trying to set up a panel that appears on a page that prompts a user
to enter in a note. This panel object is initially invisable and appears
when the user clicks on a button. Contained within the panel are a couple
of buttons and a textbox. Code is as follows:
ASPX page:
--
<%@dotnet.itags.org. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
autoeventwireup="False" %>
<html>
<form>
...
<td align="middle">
<asp:Button id="btnAddNote" runat="server" Text="Add New
Note"></asp:Button>
</td>
...
<asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid; BORDER-TOP:
black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
265px" runat="server" Width="360px" Visible="False" HorizontalAlign="Left">
<p>
<strong>Add Note:</strong>
</p>
<p align="center">
<asp:TextBox id="txAddNote" runat="server" Columns="35"
AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnSaveNote" runat="server" Text="Save Note"
Enabled="True" Visible="True"></asp:Button>
<asp:Button id="btnCancelNote" runat="server" Text="Cancel"
Enabled="True" Visible="True"></asp:Button>
<br />
<br />
</p>
</asp:Panel>
...
</form>
</html>
VB code:
--
Imports ...
Public Class CustProfile
'For PostBack
Inherits Page
Protected txtAddNote as TextBox
Protected pnlAddNote as Panel
Protected WithEvents btnAddNote as Button
...
Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
btnAddNote.Click
txtAddNote.Text = ""
pnlAddNote.Visible = True
End Sub
...
End Class
And this is the error message I get which makes no sense to me because the
object is declared and exists in both files.
Browser Msg:
--
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 422:
Line 423: Private Sub btnAddNote_Click(source as Object, e as EventArgs)
Handles btnAddNote.Click
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visible = True
Line 426: End Sub
Source File: C:\Inetpub\wwwroot\incident\cust\CustPro
file.vb Line: 424
If anyone can shed some light on this subject (namely point out what I'm
doing wrong) it would be greatly appreciated.
A. Nonymous (slightly dazed and )Please disregard this post.
I think I've found a way using JavaScript.
"A. Nonymous" <anonymous@.hotmail.com> wrote in message
news:2PCdnXTBrr8cIXvcRVn-oQ@.giganews.com...
> Hello,
> I am trying to set up a panel that appears on a page that prompts a
user
> to enter in a note. This panel object is initially invisable and appears
> when the user clicks on a button. Contained within the panel are a couple
> of buttons and a textbox. Code is as follows:
> ASPX page:
> --
> <%@. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
> autoeventwireup="False" %>
> <html>
> <form>
> ...
> <td align="middle">
> <asp:Button id="btnAddNote" runat="server" Text="Add New
> Note"></asp:Button>
> </td>
> ...
> <asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid;
BORDER-TOP:
> black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
> black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
> 265px" runat="server" Width="360px" Visible="False"
HorizontalAlign="Left">
> <p>
> <strong>Add Note:</strong>
> </p>
> <p align="center">
> <asp:TextBox id="txAddNote" runat="server" Columns="35"
> AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
> Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
> </p>
> <p align="center">
> <asp:Button id="btnSaveNote" runat="server" Text="Save
Note"
> Enabled="True" Visible="True"></asp:Button>
>
> <asp:Button id="btnCancelNote" runat="server"
Text="Cancel"
> Enabled="True" Visible="True"></asp:Button>
> <br />
> <br />
> </p>
> </asp:Panel>
> ...
> </form>
> </html>
>
> VB code:
> --
> Imports ...
> Public Class CustProfile
> 'For PostBack
> Inherits Page
> Protected txtAddNote as TextBox
> Protected pnlAddNote as Panel
> Protected WithEvents btnAddNote as Button
> ...
> Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
> btnAddNote.Click
> txtAddNote.Text = ""
> pnlAddNote.Visible = True
> End Sub
> ...
> End Class
>
> And this is the error message I get which makes no sense to me because the
> object is declared and exists in both files.
> Browser Msg:
> --
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> Line 422:
> Line 423: Private Sub btnAddNote_Click(source as Object, e as
EventArgs)
> Handles btnAddNote.Click
> Line 424: txtAddNote.Text = ""
> Line 425: pnlAddNote.Visible = True
> Line 426: End Sub
> Source File: C:\Inetpub\wwwroot\incident\cust\CustPro
file.vb Line: 424
> If anyone can shed some light on this subject (namely point out what I'm
> doing wrong) it would be greatly appreciated.
> A. Nonymous (slightly dazed and )
>
I figured out the problem:
txtAddNote.Text = "" (empty string) causes the problem
I alternatively used:
txtAddNote.Text = " " (a space)
...and all is well.
Sigh!
"A. Nonymous" <anonymous@.hotmail.com> wrote in message
news:2PCdnXTBrr8cIXvcRVn-oQ@.giganews.com...
> Hello,
> I am trying to set up a panel that appears on a page that prompts a
user
> to enter in a note. This panel object is initially invisable and appears
> when the user clicks on a button. Contained within the panel are a couple
> of buttons and a textbox. Code is as follows:
> ASPX page:
> --
> <%@. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
> autoeventwireup="False" %>
> <html>
> <form>
> ...
> <td align="middle">
> <asp:Button id="btnAddNote" runat="server" Text="Add New
> Note"></asp:Button>
> </td>
> ...
> <asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid;
BORDER-TOP:
> black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
> black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
> 265px" runat="server" Width="360px" Visible="False"
HorizontalAlign="Left">
> <p>
> <strong>Add Note:</strong>
> </p>
> <p align="center">
> <asp:TextBox id="txAddNote" runat="server" Columns="35"
> AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
> Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
> </p>
> <p align="center">
> <asp:Button id="btnSaveNote" runat="server" Text="Save
Note"
> Enabled="True" Visible="True"></asp:Button>
>
> <asp:Button id="btnCancelNote" runat="server"
Text="Cancel"
> Enabled="True" Visible="True"></asp:Button>
> <br />
> <br />
> </p>
> </asp:Panel>
> ...
> </form>
> </html>
>
> VB code:
> --
> Imports ...
> Public Class CustProfile
> 'For PostBack
> Inherits Page
> Protected txtAddNote as TextBox
> Protected pnlAddNote as Panel
> Protected WithEvents btnAddNote as Button
> ...
> Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
> btnAddNote.Click
> txtAddNote.Text = ""
> pnlAddNote.Visible = True
> End Sub
> ...
> End Class
>
> And this is the error message I get which makes no sense to me because the
> object is declared and exists in both files.
> Browser Msg:
> --
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> Line 422:
> Line 423: Private Sub btnAddNote_Click(source as Object, e as
EventArgs)
> Handles btnAddNote.Click
> Line 424: txtAddNote.Text = ""
> Line 425: pnlAddNote.Visible = True
> Line 426: End Sub
> Source File: C:\Inetpub\wwwroot\incident\cust\CustPro
file.vb Line: 424
> If anyone can shed some light on this subject (namely point out what I'm
> doing wrong) it would be greatly appreciated.
> A. Nonymous (slightly dazed and )
>

System.NullReferenceException on TextBox object...

Hello,

I am trying to set up a panel that appears on a page that prompts a user
to enter in a note. This panel object is initially invisable and appears
when the user clicks on a button. Contained within the panel are a couple
of buttons and a textbox. Code is as follows:

ASPX page:
---

<%@dotnet.itags.org. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
autoeventwireup="False" %>
<html>
<form>
...

<td align="middle">
<asp:Button id="btnAddNote" runat="server" Text="Add New
Note"></asp:Button>
</td>
...

<asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid; BORDER-TOP:
black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
265px" runat="server" Width="360px" Visible="False" HorizontalAlign="Left">
<p>
<strong>Add Note:</strong>
</p>
<p align="center">
<asp:TextBox id="txAddNote" runat="server" Columns="35"
AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnSaveNote" runat="server" Text="Save Note"
Enabled="True" Visible="True"></asp:Button>

<asp:Button id="btnCancelNote" runat="server" Text="Cancel"
Enabled="True" Visible="True"></asp:Button>
<br />
<br />
</p>
</asp:Panel>
...
</form>
</html
VB code:
---
Imports ...

Public Class CustProfile
'For PostBack
Inherits Page

Protected txtAddNote as TextBox
Protected pnlAddNote as Panel
Protected WithEvents btnAddNote as Button
...

Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
btnAddNote.Click
txtAddNote.Text = ""
pnlAddNote.Visible = True
End Sub

...
End Class

And this is the error message I get which makes no sense to me because the
object is declared and exists in both files.

Browser Msg:
----

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Click(source as Object, e as EventArgs)
Handles btnAddNote.Click
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visible = True
Line 426: End Sub

Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424

If anyone can shed some light on this subject (namely point out what I'm
doing wrong) it would be greatly appreciated.

A. Nonymous (slightly dazed and confused)Please disregard this post.

I think I've found a way using JavaScript.

"A. Nonymous" <anonymous@.hotmail.com> wrote in message
news:2PCdnXTBrr8cIXvcRVn-oQ@.giganews.com...
> Hello,
> I am trying to set up a panel that appears on a page that prompts a
user
> to enter in a note. This panel object is initially invisable and appears
> when the user clicks on a button. Contained within the panel are a couple
> of buttons and a textbox. Code is as follows:
> ASPX page:
> ---
> <%@. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
> autoeventwireup="False" %>
> <html>
> <form>
> ...
> <td align="middle">
> <asp:Button id="btnAddNote" runat="server" Text="Add New
> Note"></asp:Button>
> </td>
> ...
> <asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid;
BORDER-TOP:
> black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
> black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
> 265px" runat="server" Width="360px" Visible="False"
HorizontalAlign="Left">
> <p>
> <strong>Add Note:</strong>
> </p>
> <p align="center">
> <asp:TextBox id="txAddNote" runat="server" Columns="35"
> AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
> Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
> </p>
> <p align="center">
> <asp:Button id="btnSaveNote" runat="server" Text="Save
Note"
> Enabled="True" Visible="True"></asp:Button>
>
> <asp:Button id="btnCancelNote" runat="server"
Text="Cancel"
> Enabled="True" Visible="True"></asp:Button>
> <br />
> <br />
> </p>
> </asp:Panel>
> ...
> </form>
> </html>
>
> VB code:
> ---
> Imports ...
> Public Class CustProfile
> 'For PostBack
> Inherits Page
> Protected txtAddNote as TextBox
> Protected pnlAddNote as Panel
> Protected WithEvents btnAddNote as Button
> ...
> Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
> btnAddNote.Click
> txtAddNote.Text = ""
> pnlAddNote.Visible = True
> End Sub
> ...
> End Class
>
> And this is the error message I get which makes no sense to me because the
> object is declared and exists in both files.
> Browser Msg:
> ----
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> Line 422:
> Line 423: Private Sub btnAddNote_Click(source as Object, e as
EventArgs)
> Handles btnAddNote.Click
> Line 424: txtAddNote.Text = ""
> Line 425: pnlAddNote.Visible = True
> Line 426: End Sub
> Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424
> If anyone can shed some light on this subject (namely point out what I'm
> doing wrong) it would be greatly appreciated.
> A. Nonymous (slightly dazed and confused)
I figured out the problem:

txtAddNote.Text = "" (empty string) causes the problem

I alternatively used:

txtAddNote.Text = " " (a space)

...and all is well.

Sigh!

"A. Nonymous" <anonymous@.hotmail.com> wrote in message
news:2PCdnXTBrr8cIXvcRVn-oQ@.giganews.com...
> Hello,
> I am trying to set up a panel that appears on a page that prompts a
user
> to enter in a note. This panel object is initially invisable and appears
> when the user clicks on a button. Contained within the panel are a couple
> of buttons and a textbox. Code is as follows:
> ASPX page:
> ---
> <%@. Page Language="VB" Inherits="CustProfile" src="http://pics.10026.com/?src=CustProfile.vb"
> autoeventwireup="False" %>
> <html>
> <form>
> ...
> <td align="middle">
> <asp:Button id="btnAddNote" runat="server" Text="Add New
> Note"></asp:Button>
> </td>
> ...
> <asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid;
BORDER-TOP:
> black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
> black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
> 265px" runat="server" Width="360px" Visible="False"
HorizontalAlign="Left">
> <p>
> <strong>Add Note:</strong>
> </p>
> <p align="center">
> <asp:TextBox id="txAddNote" runat="server" Columns="35"
> AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
> Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
> </p>
> <p align="center">
> <asp:Button id="btnSaveNote" runat="server" Text="Save
Note"
> Enabled="True" Visible="True"></asp:Button>
>
> <asp:Button id="btnCancelNote" runat="server"
Text="Cancel"
> Enabled="True" Visible="True"></asp:Button>
> <br />
> <br />
> </p>
> </asp:Panel>
> ...
> </form>
> </html>
>
> VB code:
> ---
> Imports ...
> Public Class CustProfile
> 'For PostBack
> Inherits Page
> Protected txtAddNote as TextBox
> Protected pnlAddNote as Panel
> Protected WithEvents btnAddNote as Button
> ...
> Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
> btnAddNote.Click
> txtAddNote.Text = ""
> pnlAddNote.Visible = True
> End Sub
> ...
> End Class
>
> And this is the error message I get which makes no sense to me because the
> object is declared and exists in both files.
> Browser Msg:
> ----
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> Line 422:
> Line 423: Private Sub btnAddNote_Click(source as Object, e as
EventArgs)
> Handles btnAddNote.Click
> Line 424: txtAddNote.Text = ""
> Line 425: pnlAddNote.Visible = True
> Line 426: End Sub
> Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424
> If anyone can shed some light on this subject (namely point out what I'm
> doing wrong) it would be greatly appreciated.
> A. Nonymous (slightly dazed and confused)

system.nullreferenceexception problem

can anybody solve or tell more about this problem

System.NullReferenceException: Object reference not set to an instance of an object

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.ApplicationBlocks.UIProcess.WebFormViewManager.GetViewNameForCurrentRequest(IView currentView) +99
Microsoft.ApplicationBlocks.UIProcess.Navigator.GetControllerForView(IView view) +89
Microsoft.ApplicationBlocks.UIProcess.WebFormView.WebFormView_Load(Object sender, EventArgs e) +312
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +733

Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300

thanks

this is not enough info to tell you exactly what you are doing wrong, but - you are calling on a variable that you did not assign a value to. It could be something as simple as:

int a; // giving it no value

int b = a; // as you can see, you didnt *** value into a, so you are calling on a null value


this is not enough info to tell you exactly what you are doing wrong, but - you are calling on a variable that you did not assign a value to. It could be something as simple as:

int a; // giving it no value

int b = a; // as you can see, you didnt put a value into a, so you are calling on a null value


Please provide the code so we can look into the problem!

Thanks for replies.

actually i m totally new to asp.net. i have to modify an already existing project. so its more confusing bcoz i dont know very much about the actual code. the strange thing i notice that website run properly for some time at starting. and after some time it will show nothing except the system.nullreference exception on each page. does this information help to u understand the problem??

is it related to something like cache expired? i dont know abt this problem and that's why i m searching net for a solution.

thanks

System.NullReferenceException: Object reference not set to an

Hi Ken and thanks for the reply! (My Code below!!!)
What i'm trying to do is a datagrid that has Add,Update,Delete commands.My
Add command is working but my Delete and Update command is giving error :-
System.NullReferenceException: Object reference not set to an instance of an
object.
Refering to the line code:- ItemNumber =
CType(Args.Item.FindControl("ItemNumber"), TextBox).Text
Don't know whats wrong IT WORKS WITH ASP.NETWEBMATRIX!!
But VS.Net give such errors!
Any help Thanks!!
'Option Explicit On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Public Class datagrid_edit_delete
Inherits System.Web.UI.Page
'Dim ItemTypes As New ArrayList
Protected ItemTypes As New ArrayList
'Protected WithEvents ItemType As System.Web.UI.WebControls.DropDownList
Protected WithEvents Button As System.Web.UI.WebControls.Button
Protected WithEvents PageButtons As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents UpdateMessage As System.Web.UI.WebControls.Label
Protected WithEvents DataGridDisplay As System.Web.UI.WebControls.DataGrid
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
'Dim ItemNumberList As New ArrayList
'Protected WithEvents ItemTypes As System.Web.UI.WebControls.DropDownList
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
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
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
Dim PageSize As Integer = 6
'-- Load array ItemNumberList with item numbers
'Dim ItemNumberList = New ArrayList
Dim ItemNumberList = New ArrayList
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
SQLString = "SELECT ItemNumber FROM products1 ORDER BY ItemNumber"
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
ItemNumberList.Add(DBReader("ItemNumber"))
End While
DBReader.Close()
DBConnection.Close()
ItemNumberList.TrimToSize()
'-- Create Paging Buttons
Dim StartIndex = 0
Dim EndIndex As Integer
Dim StartKey As String
Dim EndKey As String
Dim i As Integer
PageButtons.Controls.Clear()
For i = 1 To Math.Ceiling(ItemNumberList.Count / PageSize)
EndIndex = StartIndex + PageSize - 1
If EndIndex > ItemNumberList.Count - 1 Then
EndIndex = ItemNumberList.Count - 1
End If
StartKey = ItemNumberList(StartIndex)
EndKey = ItemNumberList(EndIndex)
Dim PageButton As Button
PageButton = New Button
PageButton.Text = i
PageButton.ID = "P" & i
PageButton.CommandName = StartKey & "|" & EndKey
PageButton.Style("width") = "20px"
PageButton.Style("background-color") = "#F0F0F0"
AddHandler PageButton.Command, AddressOf GetPage
PageButtons.Controls.Add(PageButton)
StartIndex += PageSize
Next
'== CREATE ARRAYLIST FOR BINDING ITEM TYPES
ItemTypes = New ArrayList
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
SQLString = "SELECT DISTINCT ItemType FROM products1 ORDER BY
ItemType"
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
ItemTypes.Add(DBReader("ItemType"))
End While
DBReader.Close()
DBConnection.Close()
If Not Page.IsPostBack Or ViewState("Updated") = True Then
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
SQLString = "SELECT TOP " & PageSize & " * FROM products1 ORDER
BY ItemNumber"
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
DataGridDisplay.DataSource = DBReader
DataGridDisplay.DataBind()
DBReader.Close()
DBConnection.Close()
Dim FirstButton As Button
FirstButton = CType(PageButtons.FindControl("P1"), Button)
FirstButton.Style("background-color") = "#990000"
FirstButton.Style("color") = "#FFFFFF"
ViewState("Updated") = False
End If
End Sub
Sub GetPage(ByVal Src As Object, ByVal Args As CommandEventArgs)
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
Dim Keys() As String
Keys = Split(Args.CommandName, "|")
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
SQLString = "SELECT * FROM products1 WHERE " & _
"ItemNumber >= '" & Keys(0) & "' AND " & _
"ItemNumber <= '" & Keys(1) & "' " & _
"ORDER BY ItemNumber"
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
DataGridDisplay.DataSource = DBReader
DataGridDisplay.DataBind()
DBReader.Close()
DBConnection.Close()
'-- Highlight clicked button
Dim Item As Button
Dim ThisButton As Button
For Each Item In PageButtons.Controls
ThisButton = CType(Item, Button)
ThisButton.Style("background-color") = "#F0F0F0"
ThisButton.Style("color") = "#000000"
Next
ThisButton = CType(PageButtons.FindControl(Src.id), Button)
ThisButton.Style("background-color") = "#990000"
ThisButton.Style("color") = "#FFFFFF"
End Sub
Function SetIndex(ByVal TheItem As String)
Dim i As Integer
For i = 0 To ItemTypes.Count - 1
If TheItem = ItemTypes(i) Then
Return i
End If
Next
End Function
Sub EditRecord(ByVal Src As Object, ByVal Args As
DataGridCommandEventArgs)
Dim Command As String
Dim ItemNumber As String
Dim ItemType As String
Dim ItemSupplier As String
Dim ItemName As String
Dim ItemDescription As String
Dim ItemPrice As String
Dim ItemQuantity As String
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
Command = Args.CommandSource.Text
ItemNumber = CType(Args.Item.FindControl("ItemNumber"), TextBox).Text
ItemType = CType(Args.Item.FindControl("ItemType"),
DropDownList).SelectedItem.Text
ItemSupplier = CType(Args.Item.FindControl("ItemSupplier"),
TextBox).Text
ItemName = CType(Args.Item.FindControl("ItemName"), TextBox).Text
ItemDescription = CType(Args.Item.FindControl("ItemDescription"),
TextBox).Text
ItemPrice = CType(Args.Item.FindControl("ItemPrice"), TextBox).Text
ItemQuantity = CType(Args.Item.FindControl("ItemQuantity"),
TextBox).Text
UpdateMessage.Text = " "
Dim ValidRecord As Boolean = True
If Command = "Add" Or Command = "Update" Then
'-- CHECK FOR VALID RECORD --
'-- Check for valid ItemNumber
If Len(ItemNumber) <> 6 Then
UpdateMessage.Text &= "- Invalid Item Number length "
ValidRecord = False
ElseIf Not IsNumeric(Right(ItemNumber, 4)) Then
UpdateMessage.Text &= "- Invalid Item Number format "
ValidRecord = False
Else
ItemNumber = UCase(ItemNumber)
End If
'-- Check for missing Item Supplier
If ItemSupplier = "" Then
UpdateMessage.Text &= "- Missing Supplier "
ValidRecord = False
End If
'-- Check for missing Item Name
If ItemName = "" Then
UpdateMessage.Text &= "- Missing Name "
ValidRecord = False
End If
'-- Check for missing Item Description
If ItemDescription = "" Then
UpdateMessage.Text &= "- Missing Description "
ValidRecord = False
End If
'-- Check for valid Item Price
If Not IsNumeric(ItemPrice) Then
UpdateMessage.Text &= "- Invalid Price format "
ValidRecord = False
End If
'-- Check for valid Item Quantity
If Not IsNumeric(ItemQuantity) Then
UpdateMessage.Text &= "- Invalid Quantity format "
ValidRecord = False
End If
If ValidRecord = True And Command = "Add" Then
'-- CHECK FOR DUPLICATE RECORD --
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
SQLString = "SELECT Count(*) FROM products1 WHERE ItemNumber
= '" & ItemNumber & "'"
DBCommand = New SqlCommand(SQLString, DBConnection)
If DBCommand.ExecuteScalar() <> 0 Then
UpdateMessage.Text = "- Duplicate Item Number. Record
not added."
ValidRecord = False
End If
DBConnection.Close()
End If
End If
If ValidRecord = True Then
Select Case Command
Case "Add"
SQLString = "INSERT INTO products1 " & _
"(ItemNumber, ItemType, ItemSupplier, ItemName, " & _
"ItemDescription, ItemPrice, ItemQuantity) VALUES(" & _
"'" & ItemNumber & "', " & _
"'" & ItemType & "', " & _
"'" & Replace(ItemSupplier, "'", "''") & "', " & _
"'" & Replace(ItemName, "'", "''") & "', " & _
"'" & Replace(ItemDescription, "'", "''") & "', " & _
ItemPrice & ", " & _
ItemQuantity & ")"
UpdateMessage.Text = "- Record " & ItemNumber & " added"
Case "Update"
SQLString = "UPDATE products1 SET " & _
"ItemType = '" & ItemType & "', " & _
"ItemSupplier = '" & Replace(ItemSupplier, "'", "''")
& "', " & _
"ItemName = '" & Replace(ItemName, "'", "''") & "', "
& _
"ItemDescription = '" & Replace(ItemDescription, "'",
"''") & "', " & _
"ItemPrice = " & ItemPrice & ", " & _
"ItemQuantity = " & ItemQuantity & " " & _
"WHERE ItemNumber = '" & ItemNumber & "'"
UpdateMessage.Text = "- Record " & ItemNumber & " updated"
Case "Delete"
SQLString = "DELETE FROM products1 WHERE ItemNumber = '"
& ItemNumber & "'"
UpdateMessage.Text = "- Record " & ItemNumber & " deleted"
End Select
DBConnection = New
SqlConnection(" server=(local);database=Northwind;integr
ated security=true;")
DBConnection.Open()
DBCommand = New SqlCommand(SQLString, DBConnection)
DBCommand.ExecuteNonQuery()
DBConnection.Close()
If Command = "Add" Or Command = "Delete" Then
ViewState("Updated") = True
Page_Load(Me, EventArgs.Empty)
'Page_Load(ByRef sender As System.Object, ByRef e As
System.EventArgs)
End If
End If
End Sub
End ClassHi,
The datagrid... The datagrid isn't my thing. I used it a couple times,
got frustrated, and wrote my own. Hopefully someone in the group can point
you in the right direction. I looked through the help file that comes with
VS.Net, in VS.Net they reference .controls(0) to CType() the control:
Sub MyDataGrid_Update(sender As Object, e As DataGridCommandEventArgs)
' For bound columns the edited value is stored in a Textbox.
' The TextBox is the 0th element in the column's cell.
Dim qtyText As TextBox = CType(e.Item.Cells(2).Controls(0), TextBox)
Dim priceText As TextBox = CType(e.Item.Cells(3).Controls(0),
TextBox)
Dim item As String = e.Item.Cells(1).Text
Dim qty As String = qtyText.Text
Dim price As String = priceText.Text
Here is the link to the full source:
"ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebUIWebControlsDataGridC
ommandEventArgsClassTopic.htm"
Open up the help and paste that in the address bar.
I would try that. I don't know why WebMatrix would work and VS.Net
wouldn't. Good luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

System.NullReferenceException: Object reference not set to an inst

I have several pages written in aspx, but sometime the aspx page return the
following error. And it hapeen, the whole web application gives this error,
that means all the aspx files get affected. Any ideas?
Here is the error:
Server Error in '/' Application.
----
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
ASPX CODE:
<%@dotnet.itags.org. Page Language="JScript" Aspcompat="true" Debug="false"
Inherits="PETestTimeMSP" src="http://pics.10026.com/?src=source/pettmailmsp.js" %>
<%
pettMailMSP();
%>
<html>
<head>
<title>SCReliabilityServices Emailer</title>
</head>
<body>
SCReliabilityServices Emailer - Sent!
</body>
</html>
SOURCE CODE:
import System;
import System.Data;
import System.Data.OleDb;
import System.Web.UI;
import System.Web.UI.WebControls;
import System.Web.UI.HtmlControls;
import System.Text;
import System.Web.Mail;
import DBConn;
import LDAPCOM;
public class PETestTimeMSP extends Page {
public function sendMail(message : String, to : String) : void {
var Mailer : MailMessage = new MailMessage();
Mailer.Priority = MailPriority.Normal;
Mailer.BodyFormat = MailFormat.Html;
Mailer.From = "manager@dotnet.itags.org.email.com";
Mailer.To = to;
Mailer.Subject = "(MSP) DRTL PE Test Time Forecast - " + (new
Date().getMonth()+1) + "/" + new Date().getDate() + "/" + new
Date().getYear();
//Mailer.Body = "<font color=blue face=Arial size=-1>Starting today, you
will be receiving a daily report that should be beneficial in planning test
time<br>for jobs being stressed in DRTL.<br><br>The first part of the report
“Completed Stress – Pending Test” shows jobs that have completed stres
s
and<br>are pending test. For jobs in this status, electrical test has not
yet been completed - according to our database.<br>These will continue to
stay open, until data is provided to close.<br>If you have contacted our lab
on some of these jobs for closure, we are working on them.<br><b>Otherwise,
please contact Jennifer McClellan.</b><br><br>The second part of the report
“Forecast Readpoints for Test” is a forecast for jobs that are in<br>str
ess
and are expected to be completed within the next 5 days.<br>The time out on
the expected day is the end of the day.<br><br>Regards,<br>David
Kaase<br>DRTL Manager</font><br><br>" + message;
Mailer.Body = message;
SmtpMail.SmtpServer = "smtp.mail.ti.com";
SmtpMail.Send(Mailer);
}
public function pettMailMSP() : String {
var DBConnUtil : DBConnQDW = new DBConnQDW();
var dbconn : OleDbConnection = DBConnUtil.connectQDW();
var sql : String = "select d.relcode, d.jobtitle, d.pengrname,
d.pengremail, d.priority, t.testtype, t.testnum, r.grp, r.readnum, r.hrcy,
r.qty, to_char(k.sent, 'MM/DD/YYYY') sent, to_char(k.expecteddate,
'MM/DD/YYYY') expecteddate, k.location from rel_device d, rel_tests t,
rel_reads r, rel_track k where d.relcode = t.relcode and t.relcode =
r.relcode and t.testnum = r.testnum and r.relcode = k.relcode and r.testnum
=
k.testnum and r.grp = k.grp and r.readnum = k.readnum and d.dbname = 'MSPREL
'
and t.status = 'Active' and UPPER(t.programno) like 'ENG%' and k.complete is
null and k.location = 'PE Test'"
+ " union "
+ "select d.relcode, d.jobtitle, d.pengrname,
d.pengremail, d.priority, t.testtype, t.testnum, r.grp, r.readnum, r.hrcy,
r.qty, to_char(k.sent, 'MM/DD/YYYY') sent, to_char(k.expecteddate,
'MM/DD/YYYY') expecteddate, k.location from rel_device d, rel_tests t,
rel_reads r, rel_track k where d.relcode = t.relcode and t.relcode =
r.relcode and t.testnum = r.testnum and r.relcode = k.relcode and r.testnum
=
k.testnum and r.grp = k.grp and r.readnum = k.readnum and d.dbname = 'MSPREL
'
and t.status = 'Active' and ((t.testnum >= 0001 and t.testnum <= 0104) or
(t.testnum >= 1000 and t.testnum <= 1615) or (t.testnum >= 2000 and t.testnu
m
<= 2750) or (t.testnum >= 3000 and t.testnum <= 3240) or (t.testnum >= 3500
and t.testnum <= 3800) or (t.testnum >= 4075 and t.testnum <= 4322) or
(t.testnum = 9001)) and UPPER(t.programno) like 'ENG%' and k.expecteddate is
not null and k.expecteddate <= sysdate+5 and k.complete is null and
k.location like 'DRTL-%' order by 3, 5, 1, 6, 8, 12, 13";
var dbcmd : OleDbCommand = new OleDbCommand(sql, dbconn);
var dbRecords : OleDbDataReader = dbcmd.ExecuteReader();
var tableA : StringBuilder = new StringBuilder();
var tableB : StringBuilder = new StringBuilder();
var tableC : StringBuilder = new StringBuilder();
var tableS1 : StringBuilder = new StringBuilder();
var tableS2 : StringBuilder = new StringBuilder();
var tableS3 : StringBuilder = new StringBuilder();
var pengremail : String;
var relcodeA : String;
var relcodeB : String;
var expecteddate : String;
var tempdate : Date;
var ldaputil : LDAP = new LDAP();
while( dbRecords.Read() ) {
if( String.Compare(pengremail, dbRecords("pengremail")) != 0 ) {
if( String.Compare(pengremail, null) != 0 ) {
if( String.Compare(tableA.ToString(), "") != 0 ) {
tableA.Append("</table>");
tableC.Append(tableA.ToString());
tableC.Append("<br><br>");
}
if( String.Compare(tableB.ToString(), "") != 0 ) {
tableB.Append("</table>");
tableC.Append(tableB.ToString());
}
if( String.Compare(ldaputil.getLDAPValue('MAIL', pengremail,
'mail'), "") != 0 &&
String.Compare(tableC.ToString(), "") != 0 ) {
tableC.Append("<br>NOTE: This is an auto-generated
message!<br>");
sendMail(tableC.ToString(), pengremail);
}
}
pengremail = dbRecords("pengremail").ToString();
tableA = new StringBuilder();
tableB = new StringBuilder();
tableC = new StringBuilder();
}
if( String.Compare(dbRecords("location").ToString(), 'PE Test') == 0 ) {
if( String.Compare(tableS1.ToString(), "") == 0 ) {
tableS1.Append("<h2><font color=maroon>Completed Stress - Pending
Test</font></h2>");
tableS1.Append("<table width=75%>");
}
if( String.Compare(tableA.ToString(), "") == 0 ) {
tableA.Append("<h2><font color=maroon>Completed Stress - Pending
Test</font></h2>");
tableA.Append("<table width=75%>");
tableA.Append("<tr>");
tableA.Append("<td colspan=7><b>PE: " +
dbRecords("pengrname").ToString() + ":</b></td>");
tableA.Append("</tr>");
tableS1.Append("<tr>");
tableS1.Append("<td colspan=7><b>PE: " +
dbRecords("pengrname").ToString() + ":</b></td>");
tableS1.Append("</tr>");
}
if( String.Compare(relcodeA, dbRecords("relcode").ToString()) != 0 ) {
relcodeA = dbRecords("relcode").ToString();
tableA.Append("<tr>");
tableA.Append("<td colspan=5> <i><a
href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&Rel
code="
+ relcodeA + "'>" + relcodeA + " — " +
dbRecords("jobtitle").ToString() + "</a></i></td>");
tableA.Append("</tr>");
tableA.Append("<tr>");
tableA.Append("<td align=center><font
size=-1><b>Test_Type</b></font></td>");
tableA.Append("<td align=center><font
size=-1><b>Hr/Cy</b></font></td>");
tableA.Append("<td align=center><font
size=-1><b>Grp</b></font></td>");
tableA.Append("<td align=center><font
size=-1><b>Qty</b></font></td>");
tableA.Append("<td align=center><font
size=-1><b>PE_Test</b></font></td>");
tableA.Append("</tr>");
tableS1.Append("<tr>");
tableS1.Append("<td colspan=5> <i><a
href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&Rel
code="
+ relcodeA + "'>" + relcodeA + " — " +
dbRecords("jobtitle").ToString() + "</a></i></td>");
tableS1.Append("</tr>");
tableS1.Append("<tr>");
tableS1.Append("<td align=center><font
size=-1><b>Test_Type</b></font></td>");
tableS1.Append("<td align=center><font
size=-1><b>Hr/Cy</b></font></td>");
tableS1.Append("<td align=center><font
size=-1><b>Grp</b></font></td>");
tableS1.Append("<td align=center><font
size=-1><b>Qty</b></font></td>");
tableS1.Append("<td align=center><font
size=-1><b>PE_Test</b></font></td>");
tableS1.Append("</tr>");
}
tableA.Append("<tr>");
tableA.Append("<td align=center><font size=-1>" +
dbRecords("testtype").ToString() + "</font></td>");
tableA.Append("<td align=center><font size=-1>" +
dbRecords("hrcy").ToString() + "</font></td>");
tableA.Append("<td align=center><font size=-1>" +
dbRecords("grp").ToString() + "</font></td>");
tableA.Append("<td align=center><font size=-1>" +
dbRecords("qty").ToString() + "</font></td>");
tableA.Append("<td align=center><font size=-1>" +
dbRecords("sent").ToString() + "</font></td>");
tableA.Append("</tr>");
tableS1.Append("<tr>");
tableS1.Append("<td align=center><font size=-1>" +
dbRecords("testtype").ToString() + "</font></td>");
tableS1.Append("<td align=center><font size=-1>" +
dbRecords("hrcy").ToString() + "</font></td>");
tableS1.Append("<td align=center><font size=-1>" +
dbRecords("grp").ToString() + "</font></td>");
tableS1.Append("<td align=center><font size=-1>" +
dbRecords("qty").ToString() + "</font></td>");
tableS1.Append("<td align=center><font size=-1>" +
dbRecords("sent").ToString() + "</font></td>");
tableS1.Append("</tr>");
}
else {
expecteddate = dbRecords("expecteddate").ToString();
if( parseInt(dbRecords("testnum")) >= 1 &&
parseInt(dbRecords("testnum")) <= 104 ) {
sql = "select r_user from rel_reads where relcode = '" +
dbRecords("relcode") + "' and testnum = '" + dbRecords("testnum") + "' and
grp = '" + dbRecords("grp") + "' and readnum <= '" + dbRecords("readnum") +
"' and r_user like '%Soak%'";
var dbconnPrecon : OleDbConnection = DBConnUtil.connectQDW();
var dbcmdPrecon : OleDbCommand = new OleDbCommand(sql,
dbconnPrecon);
var dbRecordsPrecon : OleDbDataReader = dbcmdPrecon.ExecuteReader();
if( !dbRecordsPrecon.Read() ) {
dbRecordsPrecon.Close();
DBConnUtil.closeQDW(dbconnPrecon);
continue;
}
else {
tempdate = new Date(expecteddate);
tempdate.setHours(48);
if( tempdate > new Date().setHours(120) ) {
dbRecordsPrecon.Close();
DBConnUtil.closeQDW(dbconnPrecon);
continue;
}
else {
expecteddate = (new Date(tempdate).getMonth()+1) + "/" + new
Date(tempdate).getDate() + "/" + new Date(tempdate).getYear();
dbRecordsPrecon.Close();
DBConnUtil.closeQDW(dbconnPrecon);
}
}
}
if( String.Compare(tableS2.ToString(), "") == 0 ) {
tableS2.Append("<h2><font color=maroon>Forecast Readpoints for
Test</font></h2>");
tableS2.Append("<table width=75%>");
}
if( String.Compare(tableB.ToString(), "") == 0 ) {
tableB.Append("<h2><font color=maroon>Forecast Readpoints for
Test</font></h2>");
tableB.Append("<table width=75%>");
tableB.Append("<tr>");
tableB.Append("<td colspan=7><b>PE: " +
dbRecords("pengrname").ToString() + ":</b></td>");
tableB.Append("</tr>");
tableS2.Append("<tr>");
tableS2.Append("<td colspan=7><b>PE: " +
dbRecords("pengrname").ToString() + ":</b></td>");
tableS2.Append("</tr>");
}
if( String.Compare(relcodeB, dbRecords("relcode").ToString()) != 0 ) {
relcodeB = dbRecords("relcode").ToString();
tableB.Append("<tr>");
tableB.Append("<td colspan=5> <i><a
href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&Rel
code="
+ relcodeB + "'>" + relcodeB + " — " +
dbRecords("jobtitle").ToString() + "</a></i></td>");
tableB.Append("</tr>");
tableB.Append("<tr>");
tableB.Append("<td align=center><font
size=-1><b>Test_Type</b></font></td>");
tableB.Append("<td align=center><font
size=-1><b>Hr/Cy</b></font></td>");
tableB.Append("<td align=center><font
size=-1><b>Grp</b></font></td>");
tableB.Append("<td align=center><font
size=-1><b>Qty</b></font></td>");
tableB.Append("<td align=center><font
size=-1><b>Expected_Date</b></font></td>");
tableB.Append("</tr>");
tableS2.Append("<tr>");
tableS2.Append("<td colspan=5> <i><a
href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&Rel
code="
+ relcodeB + "'>" + relcodeB + " — " +
dbRecords("jobtitle").ToString() + "</a></i></td>");
tableS2.Append("</tr>");
tableS2.Append("<tr>");
tableS2.Append("<td align=center><font
size=-1><b>Test_Type</b></font></td>");
tableS2.Append("<td align=center><font
size=-1><b>Hr/Cy</b></font></td>");
tableS2.Append("<td align=center><font
size=-1><b>Grp</b></font></td>");
tableS2.Append("<td align=center><font
size=-1><b>Qty</b></font></td>");
tableS2.Append("<td align=center><font
size=-1><b>Expected_Date</b></font></td>");
tableS2.Append("</tr>");
}
tableB.Append("<tr>");
tableB.Append("<td align=center><font size=-1>" +
dbRecords("testtype").ToString() + "</font></td>");
tableB.Append("<td align=center><font size=-1>" +
dbRecords("hrcy").ToString() + "</font></td>");
tableB.Append("<td align=center><font size=-1>" +
dbRecords("grp").ToString() + "</font></td>");
tableB.Append("<td align=center><font size=-1>" +
dbRecords("qty").ToString() + "</font></td>");
tableB.Append("<td align=center><font size=-1>" + expecteddate +
"</font></td>");
tableB.Append("</tr>");
tableS2.Append("<tr>");
tableS2.Append("<td align=center><font size=-1>" +
dbRecords("testtype").ToString() + "</font></td>");
tableS2.Append("<td align=center><font size=-1>" +
dbRecords("hrcy").ToString() + "</font></td>");
tableS2.Append("<td align=center><font size=-1>" +
dbRecords("grp").ToString() + "</font></td>");
tableS2.Append("<td align=center><font size=-1>" +
dbRecords("qty").ToString() + "</font></td>");
tableS2.Append("<td align=center><font size=-1>" + expecteddate +
"</font></td>");
tableS2.Append("</tr>");
}
}
if( String.Compare(tableA.ToString(), "") != 0 ) {
tableA.Append("</table>");
tableC.Append(tableA.ToString());
tableC.Append("<br><br>");
}
if( String.Compare(tableB.ToString(), "") != 0 ) {
tableB.Append("</table>");
tableC.Append(tableB.ToString());
}
if( String.Compare(ldaputil.getLDAPValue('MAIL', pengremail, 'mail'),
"") != 0 &&
String.Compare(tableC.ToString(), "") != 0 ) {
tableC.Append("<br>NOTE: This is an auto-generated message!<br>");
sendMail(tableC.ToString(), pengremail);
}
if( String.Compare(tableS1.ToString(), "") != 0 ) {
tableS1.Append("</table>");
tableS3.Append(tableS1.ToString());
tableS3.Append("<br><br>");
}
if( String.Compare(tableS2.ToString(), "") != 0 ) {
tableS2.Append("</table>");
tableS3.Append(tableS2.ToString());
}
tableS3.Append("<br>NOTE: This is an auto-generated message!<br>");
sendMail("***Summary to Lab Manager***<br><br>" + tableS3.ToString(),
'manager@dotnet.itags.org.email.com');
dbRecords.Close();
DBConnUtil.closeQDW(dbconn);
}
}A couple of things:
Note the following in the error message:

> Please review the stack trace for more information about
> the error and where it originated in the code.
Note the following in your @.Page directive:

> <%@. Page Language="JScript" Aspcompat="true" Debug="false"
> Inherits="PETestTimeMSP" src="http://pics.10026.com/?src=source/pettmailmsp.js" %>
Turing Debugging ON should give you the stack trace that will indicate the
line of code that threw the exception. From there it's simple.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"Ben" <Ben@.discussions.microsoft.com> wrote in message
news:1AF1D1E9-E17A-40CC-BB81-94C2BD4E645F@.microsoft.com...
>I have several pages written in aspx, but sometime the aspx page return the
> following error. And it hapeen, the whole web application gives this
> error,
> that means all the aspx files get affected. Any ideas?
> Here is the error:
> Server Error in '/' Application.
> ----
--
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> ASPX CODE:
> <%@. Page Language="JScript" Aspcompat="true" Debug="false"
> Inherits="PETestTimeMSP" src="http://pics.10026.com/?src=source/pettmailmsp.js" %>
> <%
> pettMailMSP();
> %>
> <html>
> <head>
> <title>SCReliabilityServices Emailer</title>
> </head>
> <body>
> SCReliabilityServices Emailer - Sent!
> </body>
> </html>
> SOURCE CODE:
> import System;
> import System.Data;
> import System.Data.OleDb;
> import System.Web.UI;
> import System.Web.UI.WebControls;
> import System.Web.UI.HtmlControls;
> import System.Text;
> import System.Web.Mail;
> import DBConn;
> import LDAPCOM;
> public class PETestTimeMSP extends Page {
> public function sendMail(message : String, to : String) : void {
> var Mailer : MailMessage = new MailMessage();
> Mailer.Priority = MailPriority.Normal;
> Mailer.BodyFormat = MailFormat.Html;
> Mailer.From = "manager@.email.com";
> Mailer.To = to;
> Mailer.Subject = "(MSP) DRTL PE Test Time Forecast - " + (new
> Date().getMonth()+1) + "/" + new Date().getDate() + "/" + new
> Date().getYear();
> //Mailer.Body = "<font color=blue face=Arial size=-1>Starting today,
> you
> will be receiving a daily report that should be beneficial in planning
> test
> time<br>for jobs being stressed in DRTL.<br><br>The first part of the
> report
> "Completed Stress - Pending Test" shows jobs that have completed stress
> and<br>are pending test. For jobs in this status, electrical test has not
> yet been completed - according to our database.<br>These will continue to
> stay open, until data is provided to close.<br>If you have contacted our
> lab
> on some of these jobs for closure, we are working on
> them.<br><b>Otherwise,
> please contact Jennifer McClellan.</b><br><br>The second part of the
> report
> "Forecast Readpoints for Test" is a forecast for jobs that are
> in<br>stress
> and are expected to be completed within the next 5 days.<br>The time out
> on
> the expected day is the end of the day.<br><br>Regards,<br>David
> Kaase<br>DRTL Manager<br><br>" + message;
> Mailer.Body = message;
> SmtpMail.SmtpServer = "smtp.mail.ti.com";
> SmtpMail.Send(Mailer);
> }
> public function pettMailMSP() : String {
> var DBConnUtil : DBConnQDW = new DBConnQDW();
> var dbconn : OleDbConnection = DBConnUtil.connectQDW();
> var sql : String = "select d.relcode, d.jobtitle, d.pengrname,
> d.pengremail, d.priority, t.testtype, t.testnum, r.grp, r.readnum, r.hrcy,
> r.qty, to_char(k.sent, 'MM/DD/YYYY') sent, to_char(k.expecteddate,
> 'MM/DD/YYYY') expecteddate, k.location from rel_device d, rel_tests t,
> rel_reads r, rel_track k where d.relcode = t.relcode and t.relcode =
> r.relcode and t.testnum = r.testnum and r.relcode = k.relcode and
> r.testnum =
> k.testnum and r.grp = k.grp and r.readnum = k.readnum and d.dbname =
> 'MSPREL'
> and t.status = 'Active' and UPPER(t.programno) like 'ENG%' and k.complete
> is
> null and k.location = 'PE Test'"
> + " union "
> + "select d.relcode, d.jobtitle, d.pengrname,
> d.pengremail, d.priority, t.testtype, t.testnum, r.grp, r.readnum, r.hrcy,
> r.qty, to_char(k.sent, 'MM/DD/YYYY') sent, to_char(k.expecteddate,
> 'MM/DD/YYYY') expecteddate, k.location from rel_device d, rel_tests t,
> rel_reads r, rel_track k where d.relcode = t.relcode and t.relcode =
> r.relcode and t.testnum = r.testnum and r.relcode = k.relcode and
> r.testnum =
> k.testnum and r.grp = k.grp and r.readnum = k.readnum and d.dbname =
> 'MSPREL'
> and t.status = 'Active' and ((t.testnum >= 0001 and t.testnum <= 0104) or
> (t.testnum >= 1000 and t.testnum <= 1615) or (t.testnum >= 2000 and
> t.testnum
> <= 2750) or (t.testnum >= 3000 and t.testnum <= 3240) or (t.testnum >=
> 3500
> and t.testnum <= 3800) or (t.testnum >= 4075 and t.testnum <= 4322) or
> (t.testnum = 9001)) and UPPER(t.programno) like 'ENG%' and k.expecteddate
> is
> not null and k.expecteddate <= sysdate+5 and k.complete is null and
> k.location like 'DRTL-%' order by 3, 5, 1, 6, 8, 12, 13";
> var dbcmd : OleDbCommand = new OleDbCommand(sql, dbconn);
> var dbRecords : OleDbDataReader = dbcmd.ExecuteReader();
> var tableA : StringBuilder = new StringBuilder();
> var tableB : StringBuilder = new StringBuilder();
> var tableC : StringBuilder = new StringBuilder();
> var tableS1 : StringBuilder = new StringBuilder();
> var tableS2 : StringBuilder = new StringBuilder();
> var tableS3 : StringBuilder = new StringBuilder();
> var pengremail : String;
> var relcodeA : String;
> var relcodeB : String;
> var expecteddate : String;
> var tempdate : Date;
> var ldaputil : LDAP = new LDAP();
> while( dbRecords.Read() ) {
> if( String.Compare(pengremail, dbRecords("pengremail")) != 0 ) {
> if( String.Compare(pengremail, null) != 0 ) {
> if( String.Compare(tableA.ToString(), "") != 0 ) {
> tableA.Append("</table>");
> tableC.Append(tableA.ToString());
> tableC.Append("<br><br>");
> }
> if( String.Compare(tableB.ToString(), "") != 0 ) {
> tableB.Append("</table>");
> tableC.Append(tableB.ToString());
> }
> if( String.Compare(ldaputil.getLDAPValue('MAIL', pengremail,
> 'mail'), "") != 0 &&
> String.Compare(tableC.ToString(), "") != 0 ) {
> tableC.Append("<br>NOTE: This is an auto-generated
> message!<br>");
> sendMail(tableC.ToString(), pengremail);
> }
> }
> pengremail = dbRecords("pengremail").ToString();
> tableA = new StringBuilder();
> tableB = new StringBuilder();
> tableC = new StringBuilder();
> }
> if( String.Compare(dbRecords("location").ToString(), 'PE Test') ==
> 0 ) {
> if( String.Compare(tableS1.ToString(), "") == 0 ) {
> tableS1.Append("<h2><font color=maroon>Completed Stress - Pending
> Test</h2>");
> tableS1.Append("<table width=75%>");
> }
> if( String.Compare(tableA.ToString(), "") == 0 ) {
> tableA.Append("<h2><font color=maroon>Completed Stress - Pending
> Test</h2>");
> tableA.Append("<table width=75%>");
> tableA.Append("<tr>");
> tableA.Append("<td colspan=7><b>PE: " +
> dbRecords("pengrname").ToString() + ":</b></td>");
> tableA.Append("</tr>");
> tableS1.Append("<tr>");
> tableS1.Append("<td colspan=7><b>PE: " +
> dbRecords("pengrname").ToString() + ":</b></td>");
> tableS1.Append("</tr>");
> }
> if( String.Compare(relcodeA, dbRecords("relcode").ToString()) !=
> 0 ) {
> relcodeA = dbRecords("relcode").ToString();
> tableA.Append("<tr>");
> tableA.Append("<td colspan=5> <i><a
> href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&R
elcode="
> + relcodeA + "'>" + relcodeA + " - " +
> dbRecords("jobtitle").ToString() + "</a></i></td>");
> tableA.Append("</tr>");
> tableA.Append("<tr>");
> tableA.Append("<td align=center><font
> size=-1><b>Test_Type</b></td>");
> tableA.Append("<td align=center><font
> size=-1><b>Hr/Cy</b></td>");
> tableA.Append("<td align=center><font
> size=-1><b>Grp</b></td>");
> tableA.Append("<td align=center><font
> size=-1><b>Qty</b></td>");
> tableA.Append("<td align=center><font
> size=-1><b>PE_Test</b></td>");
> tableA.Append("</tr>");
> tableS1.Append("<tr>");
> tableS1.Append("<td colspan=5> <i><a
> href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&R
elcode="
> + relcodeA + "'>" + relcodeA + " - " +
> dbRecords("jobtitle").ToString() + "</a></i></td>");
> tableS1.Append("</tr>");
> tableS1.Append("<tr>");
> tableS1.Append("<td align=center><font
> size=-1><b>Test_Type</b></td>");
> tableS1.Append("<td align=center><font
> size=-1><b>Hr/Cy</b></td>");
> tableS1.Append("<td align=center><font
> size=-1><b>Grp</b></td>");
> tableS1.Append("<td align=center><font
> size=-1><b>Qty</b></td>");
> tableS1.Append("<td align=center><font
> size=-1><b>PE_Test</b></td>");
> tableS1.Append("</tr>");
> }
> tableA.Append("<tr>");
> tableA.Append("<td align=center><font size=-1>" +
> dbRecords("testtype").ToString() + "</td>");
> tableA.Append("<td align=center><font size=-1>" +
> dbRecords("hrcy").ToString() + "</td>");
> tableA.Append("<td align=center><font size=-1>" +
> dbRecords("grp").ToString() + "</td>");
> tableA.Append("<td align=center><font size=-1>" +
> dbRecords("qty").ToString() + "</td>");
> tableA.Append("<td align=center><font size=-1>" +
> dbRecords("sent").ToString() + "</td>");
> tableA.Append("</tr>");
> tableS1.Append("<tr>");
> tableS1.Append("<td align=center><font size=-1>" +
> dbRecords("testtype").ToString() + "</td>");
> tableS1.Append("<td align=center><font size=-1>" +
> dbRecords("hrcy").ToString() + "</td>");
> tableS1.Append("<td align=center><font size=-1>" +
> dbRecords("grp").ToString() + "</td>");
> tableS1.Append("<td align=center><font size=-1>" +
> dbRecords("qty").ToString() + "</td>");
> tableS1.Append("<td align=center><font size=-1>" +
> dbRecords("sent").ToString() + "</td>");
> tableS1.Append("</tr>");
> }
> else {
> expecteddate = dbRecords("expecteddate").ToString();
> if( parseInt(dbRecords("testnum")) >= 1 &&
> parseInt(dbRecords("testnum")) <= 104 ) {
> sql = "select r_user from rel_reads where relcode = '" +
> dbRecords("relcode") + "' and testnum = '" + dbRecords("testnum") + "' and
> grp = '" + dbRecords("grp") + "' and readnum <= '" + dbRecords("readnum")
> +
> "' and r_user like '%Soak%'";
> var dbconnPrecon : OleDbConnection = DBConnUtil.connectQDW();
> var dbcmdPrecon : OleDbCommand = new OleDbCommand(sql,
> dbconnPrecon);
> var dbRecordsPrecon : OleDbDataReader =
> dbcmdPrecon.ExecuteReader();
> if( !dbRecordsPrecon.Read() ) {
> dbRecordsPrecon.Close();
> DBConnUtil.closeQDW(dbconnPrecon);
> continue;
> }
> else {
> tempdate = new Date(expecteddate);
> tempdate.setHours(48);
> if( tempdate > new Date().setHours(120) ) {
> dbRecordsPrecon.Close();
> DBConnUtil.closeQDW(dbconnPrecon);
> continue;
> }
> else {
> expecteddate = (new Date(tempdate).getMonth()+1) + "/" + new
> Date(tempdate).getDate() + "/" + new Date(tempdate).getYear();
> dbRecordsPrecon.Close();
> DBConnUtil.closeQDW(dbconnPrecon);
> }
> }
> }
> if( String.Compare(tableS2.ToString(), "") == 0 ) {
> tableS2.Append("<h2><font color=maroon>Forecast Readpoints for
> Test</h2>");
> tableS2.Append("<table width=75%>");
> }
> if( String.Compare(tableB.ToString(), "") == 0 ) {
> tableB.Append("<h2><font color=maroon>Forecast Readpoints for
> Test</h2>");
> tableB.Append("<table width=75%>");
> tableB.Append("<tr>");
> tableB.Append("<td colspan=7><b>PE: " +
> dbRecords("pengrname").ToString() + ":</b></td>");
> tableB.Append("</tr>");
> tableS2.Append("<tr>");
> tableS2.Append("<td colspan=7><b>PE: " +
> dbRecords("pengrname").ToString() + ":</b></td>");
> tableS2.Append("</tr>");
> }
> if( String.Compare(relcodeB, dbRecords("relcode").ToString()) !=
> 0 ) {
> relcodeB = dbRecords("relcode").ToString();
> tableB.Append("<tr>");
> tableB.Append("<td colspan=5> <i><a
> href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&R
elcode="
> + relcodeB + "'>" + relcodeB + " - " +
> dbRecords("jobtitle").ToString() + "</a></i></td>");
> tableB.Append("</tr>");
> tableB.Append("<tr>");
> tableB.Append("<td align=center><font
> size=-1><b>Test_Type</b></td>");
> tableB.Append("<td align=center><font
> size=-1><b>Hr/Cy</b></td>");
> tableB.Append("<td align=center><font
> size=-1><b>Grp</b></td>");
> tableB.Append("<td align=center><font
> size=-1><b>Qty</b></td>");
> tableB.Append("<td align=center><font
> size=-1><b>Expected_Date</b></td>");
> tableB.Append("</tr>");
> tableS2.Append("<tr>");
> tableS2.Append("<td colspan=5> <i><a
> href='http://reldb.sc.ti.com/reldb/reldbmain.nsf/ShowJobDetail?OpenAgent&R
elcode="
> + relcodeB + "'>" + relcodeB + " - " +
> dbRecords("jobtitle").ToString() + "</a></i></td>");
> tableS2.Append("</tr>");
> tableS2.Append("<tr>");
> tableS2.Append("<td align=center><font
> size=-1><b>Test_Type</b></td>");
> tableS2.Append("<td align=center><font
> size=-1><b>Hr/Cy</b></td>");
> tableS2.Append("<td align=center><font
> size=-1><b>Grp</b></td>");
> tableS2.Append("<td align=center><font
> size=-1><b>Qty</b></td>");
> tableS2.Append("<td align=center><font
> size=-1><b>Expected_Date</b></td>");
> tableS2.Append("</tr>");
> }
> tableB.Append("<tr>");
> tableB.Append("<td align=center><font size=-1>" +
> dbRecords("testtype").ToString() + "</td>");
> tableB.Append("<td align=center><font size=-1>" +
> dbRecords("hrcy").ToString() + "</td>");
> tableB.Append("<td align=center><font size=-1>" +
> dbRecords("grp").ToString() + "</td>");
> tableB.Append("<td align=center><font size=-1>" +
> dbRecords("qty").ToString() + "</td>");
> tableB.Append("<td align=center><font size=-1>" + expecteddate +
> "</td>");
> tableB.Append("</tr>");
> tableS2.Append("<tr>");
> tableS2.Append("<td align=center><font size=-1>" +
> dbRecords("testtype").ToString() + "</td>");
> tableS2.Append("<td align=center><font size=-1>" +
> dbRecords("hrcy").ToString() + "</td>");
> tableS2.Append("<td align=center><font size=-1>" +
> dbRecords("grp").ToString() + "</td>");
> tableS2.Append("<td align=center><font size=-1>" +
> dbRecords("qty").ToString() + "</td>");
> tableS2.Append("<td align=center><font size=-1>" + expecteddate +
> "</td>");
> tableS2.Append("</tr>");
> }
> }
> if( String.Compare(tableA.ToString(), "") != 0 ) {
> tableA.Append("</table>");
> tableC.Append(tableA.ToString());
> tableC.Append("<br><br>");
> }
> if( String.Compare(tableB.ToString(), "") != 0 ) {
> tableB.Append("</table>");
> tableC.Append(tableB.ToString());
> }
> if( String.Compare(ldaputil.getLDAPValue('MAIL', pengremail, 'mail'),
> "") != 0 &&
> String.Compare(tableC.ToString(), "") != 0 ) {
> tableC.Append("<br>NOTE: This is an auto-generated message!<br>");
> sendMail(tableC.ToString(), pengremail);
> }
> if( String.Compare(tableS1.ToString(), "") != 0 ) {
> tableS1.Append("</table>");
> tableS3.Append(tableS1.ToString());
> tableS3.Append("<br><br>");
> }
> if( String.Compare(tableS2.ToString(), "") != 0 ) {
> tableS2.Append("</table>");
> tableS3.Append(tableS2.ToString());
> }
> tableS3.Append("<br>NOTE: This is an auto-generated message!<br>");
> sendMail("***Summary to Lab Manager***<br><br>" + tableS3.ToString(),
> 'manager@.email.com');
> dbRecords.Close();
> DBConnUtil.closeQDW(dbconn);
> }
> }
>
Adam,
This is aspnet user group. <%# %> code is ASP. Yes a few things are still
used <% %> this is only available for backwards compatibility not new
development.
Use the page_load or Page_render events for processing the querry string
into your control.
Bad luck
"Adam Knight" wrote:

> Hi all,
> I have the following peice of code:
> Esssentially, a querystring containing a comma separated list of values is
> used to populate the appropriate intSectionID property of a user control.
> <% If Not(Request.QueryString("SectionID") Is Nothing) Then %>
> <% arrSectionID = Split(Request.QueryString("SectionID"), ",") %>
> <Company:Links ID="LevelTwo" intSectionID="<%# arrSectionID(0) %>"
> Runat="Server"/>
> <% End If %>
> However i keep gettting the error listed in my post..
> Can someone fill me in on what could be going wrong?
> I have a suspicion it may be occuring when the User Controls DataBind meth
od
> is called.
> The variable is visible to the parent page, but not the user control'
> Suggest a way to fix?
> Cheers,
> Adam
>
>