Saturday, March 31, 2012
There is no row at ...
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
Panel2.Visible = false;
Panel1.Visible = true;
Label1.Text = "Logged in as: " + Session["VisitorsName"];
sqlConnection1.Open();
sqlFilesIDAdapter.SelectCommand.Parameters["@dotnet.itags.org.ID"].Value =
Session["VisitorsID"];
sqlFilesIDAdapter.Fill(filesIDData1,"Files");
DataGrid1.DataBind();
}
}
private void DataGrid1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Label2.Text =
filesIDData1.Tables["Files"].Rows[DataGrid1.SelectedItem.ItemIndex]["TP_
Name"].ToString();
}
Now when I click on a row I get: 'There is no row at ' and then the
number. If I remove the !IsPostBack condition it works. Why is this?
--
Kind regards,
Stijn Verrept.Because the data is loaded the first time into the grid, but the second time
you haven't loaded the data therefore the grid is empty when you change the
index. You could store the object in the Viewstate and then recover it on
further loads, though this can make for a rather large page as the Viewstate
data tends to bloat a page pretty well.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Stijn Verrept" <stijn@.no_s.p.a.n.entrysoft.com> wrote in message
news:400dc686$0$323$ba620e4c@.news.skynet.be...
> I have this code so far:
> private void Page_Load(object sender, System.EventArgs e)
> {
> if (!IsPostBack)
> {
> Panel2.Visible = false;
> Panel1.Visible = true;
> Label1.Text = "Logged in as: " + Session["VisitorsName"];
> sqlConnection1.Open();
> sqlFilesIDAdapter.SelectCommand.Parameters["@.ID"].Value =
> Session["VisitorsID"];
> sqlFilesIDAdapter.Fill(filesIDData1,"Files");
> DataGrid1.DataBind();
> }
> }
> private void DataGrid1_SelectedIndexChanged(object sender,
> System.EventArgs e)
> {
> Panel1.Visible = false;
> Panel2.Visible = true;
> Label2.Text =
> filesIDData1.Tables["Files"].Rows[DataGrid1.SelectedItem.ItemIndex]["TP_
> Name"].ToString();
> }
>
> Now when I click on a row I get: 'There is no row at ' and then the
> number. If I remove the !IsPostBack condition it works. Why is this?
> --
> Kind regards,
> Stijn Verrept.
Mark Fitzpatrick wrote:
> Because the data is loaded the first time into the grid, but the
> second time you haven't loaded the data therefore the grid is empty
> when you change the index. You could store the object in the
> Viewstate and then recover it on further loads, though this can make
> for a rather large page as the Viewstate data tends to bloat a page
> pretty well.
Thanks Mark for your answer, I understand now. But what I don't get is
why I need to reload the data if all I do is show a field in a label?
Is it possible to do this client side?
--
Kind regards,
Stijn Verrept.
I agree, I don't know that I would recommend the viewstate because it can get pretty large, depending on how much data you're talking about
One of the things I've done is if the page is not a postback then load the grid. On the SelectedIndexChanged event on the grid I do all the manipulation and whatever I need to do, then I do a response.redirect to that same page I'm already on. This works pretty well (I think) if you're programmatically doing something with the data and leaving the user out of any data manipulation. However, if you need the user to manipulate the data this won't work so well (I don't think)
HTH
Jeremy
Stijn
The reason you need to reload the data is because when a postback happens you loose all of data. I know it seems bizarre, but that's how the web works. Every HTTP request to a file (or page) acts like a brand new request, that's why in your pages you'll need to put in the appropriate checks to ensure the page is a PostBack or not
I'm not sure about working with the grid on the client though. But I hope this answers your question about why you need to reload the data
Jeremy
Stijn Verrept wrote:
> Mark Fitzpatrick wrote:
>
>>Because the data is loaded the first time into the grid, but the
>>second time you haven't loaded the data therefore the grid is empty
>>when you change the index. You could store the object in the
>>Viewstate and then recover it on further loads, though this can make
>>for a rather large page as the Viewstate data tends to bloat a page
>>pretty well.
>
> Thanks Mark for your answer, I understand now. But what I don't get is
> why I need to reload the data if all I do is show a field in a label?
> Is it possible to do this client side?
If you are looking up a value in the same table you bound to, just
create some invisible/hidden columns with the other column values you
need later on.
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Craig Deelsnyder wrote:
> If you are looking up a value in the same table you bound to, just
> create some invisible/hidden columns with the other column values you
> need later on.
Aha! Thanks :)
I changed it to Label2.Text = DataGrid1.SelectedItem.Cells[1].Text; and
this works great. I also replaced the Dataset by a DataReader which
seems to speed it up some more :)
--
Kind regards,
Stijn Verrept.
Wednesday, March 28, 2012
There was an error generating the XML document.
public string SerializeObject(object oClassObject,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}
and exception occured with message "There was an error generating the XML
document."
how can I know where is the error occured the stack trace did not give usef
info
StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133" string
line 133 where I called oSerializer.Serialize(writer,oClassObject);
Any Suggestions?And that's all the stack trace? There isn't anything more in the error
description (no description of inner exception whatsoever)?
I think you'd get replies faster by asking this at
microsoft.public.dotnet.xml group (I sent this to that group).
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Raed Sawalha" <RaedSawalha@.discussions.microsoft.com> wrote in message
news:050B90D9-6524-46CD-BB20-E1FE3BAE0367@.microsoft.com...
> Hello when I serialize an object an error generated using this function
> public string SerializeObject(object oClassObject,System.Type oClassType)
> {
> XmlSerializer oSerializer = new XmlSerializer(oClassType);
> System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
> System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
> try
> {
> oSerializer.Serialize(writer,oClassObject);
> }
> catch(InvalidOperationException ex)
> {
> string msg = ex.Message;
> string stack = ex.StackTrace;
> }
> return strBuilder.ToString();
> }
> and exception occured with message "There was an error generating the XML
> document."
> how can I know where is the error occured the stack trace did not give
> usef
> info
> StackTrace : " at
> System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
> Object
> o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
> Object
> o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
> Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
> Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
> oClassType) in d:\\scorm\\test\\form1.cs:line 133" string
> line 133 where I called oSerializer.Serialize(writer,oClassObject);
> Any Suggestions?
Can you post the definition of the class you're trying to serialize?
If the class is not serializable, the XmlSerializer is going to have a
hard time turning it into an XML document :)
Greetings,
Wessel
--Original Message--
From: Raed Sawalha [mailto:RaedSawalha@.discussions.microsoft.com]
Posted At: Sunday, April 10, 2005 11:25 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: There was an error generating the XML document.
Subject: There was an error generating the XML document.
Hello when I serialize an object an error generated using this function
public string SerializeObject(object oClassObject,System.Type
oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}
and exception occured with message "There was an error generating the
XML
document."
how can I know where is the error occured the stack trace did not give
usef
info
StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133" string
line 133 where I called oSerializer.Serialize(writer,oClassObject);
Any Suggestions?
Hello Raed,
Your code looks ok. You'll need to dig down into the InnerException ... buri
ed
down in there you'll find the root cause of the problem.
Matt Berther
http://www.mattberther.com
> Hello when I serialize an object an error generated using this
> function
> public string SerializeObject(object oClassObject,System.Type
> oClassType)
> {
> XmlSerializer oSerializer = new XmlSerializer(oClassType);
> System.Text.StringBuilder strBuilder = new
> System.Text.StringBuilder();
> System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
> try
> {
> oSerializer.Serialize(writer,oClassObject);
> }
> catch(InvalidOperationException ex)
> {
> string msg = ex.Message;
> string stack = ex.StackTrace;
> }
> return strBuilder.ToString();
> }
> and exception occured with message "There was an error generating the
> XML
> document."
> how can I know where is the error occured the stack trace did not give
> usef
> info
> StackTrace : " at
> System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
> Object o, XmlSerializerNamespaces namespaces, String
> encodingStyle)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
> Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
> textWriter, Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
> textWriter, Object o)\r\n at Test.Form1.SerializeObject(Object
> oClassObject, Type oClassType) in d:\\scorm\\test\\form1.cs:line 133"
> string
> line 133 where I called oSerializer.Serialize(writer,oClassObject);
> Any Suggestions?
>
There was an error generating the XML document.
public string SerializeObject(object oClassObject,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}
and exception occured with message "There was an error generating the XML
document."
how can I know where is the error occured the stack trace did not give usef
info
StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133"string
line 133 where I called oSerializer.Serialize(writer,oClassObject);
Any Suggestions?And that's all the stack trace? There isn't anything more in the error
description (no description of inner exception whatsoever)?
I think you'd get replies faster by asking this at
microsoft.public.dotnet.xml group (I sent this to that group).
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Raed Sawalha" <RaedSawalha@.discussions.microsoft.com> wrote in message
news:050B90D9-6524-46CD-BB20-E1FE3BAE0367@.microsoft.com...
> Hello when I serialize an object an error generated using this function
> public string SerializeObject(object oClassObject,System.Type oClassType)
> {
> XmlSerializer oSerializer = new XmlSerializer(oClassType);
> System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
> System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
> try
> {
> oSerializer.Serialize(writer,oClassObject);
> }
> catch(InvalidOperationException ex)
> {
> string msg = ex.Message;
> string stack = ex.StackTrace;
> }
> return strBuilder.ToString();
> }
> and exception occured with message "There was an error generating the XML
> document."
> how can I know where is the error occured the stack trace did not give
> usef
> info
> StackTrace : " at
> System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
> Object
> o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
> Object
> o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
> Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
> Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
> oClassType) in d:\\scorm\\test\\form1.cs:line 133" string
> line 133 where I called oSerializer.Serialize(writer,oClassObject);
> Any Suggestions?
Can you post the definition of the class you're trying to serialize?
If the class is not serializable, the XmlSerializer is going to have a
hard time turning it into an XML document :)
Greetings,
Wessel
--Original Message--
From: Raed Sawalha [mailto:RaedSawalha@.discussions.microsoft.com]
Posted At: Sunday, April 10, 2005 11:25 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: There was an error generating the XML document.
Subject: There was an error generating the XML document.
Hello when I serialize an object an error generated using this function
public string SerializeObject(object oClassObject,System.Type
oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}
and exception occured with message "There was an error generating the
XML
document."
how can I know where is the error occured the stack trace did not give
usef
info
StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133"string
line 133 where I called oSerializer.Serialize(writer,oClassObject);
Any Suggestions?
Hello Raed,
Your code looks ok. You'll need to dig down into the InnerException ... buried
down in there you'll find the root cause of the problem.
--
Matt Berther
http://www.mattberther.com
> Hello when I serialize an object an error generated using this
> function
> public string SerializeObject(object oClassObject,System.Type
> oClassType)
> {
> XmlSerializer oSerializer = new XmlSerializer(oClassType);
> System.Text.StringBuilder strBuilder = new
> System.Text.StringBuilder();
> System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
> try
> {
> oSerializer.Serialize(writer,oClassObject);
> }
> catch(InvalidOperationException ex)
> {
> string msg = ex.Message;
> string stack = ex.StackTrace;
> }
> return strBuilder.ToString();
> }
> and exception occured with message "There was an error generating the
> XML
> document."
> how can I know where is the error occured the stack trace did not give
> usef
> info
> StackTrace : " at
> System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
> Object o, XmlSerializerNamespaces namespaces, String
> encodingStyle)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
> Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
> textWriter, Object o, XmlSerializerNamespaces namespaces)\r\n at
> System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
> textWriter, Object o)\r\n at Test.Form1.SerializeObject(Object
> oClassObject, Type oClassType) in d:\\scorm\\test\\form1.cs:line 133"
> string
> line 133 where I called oSerializer.Serialize(writer,oClassObject);
> Any Suggestions?
This code doesnt work with VS2005
Dim MyConn As New SqlConnection("Server=localhost;UID=sa;PWD=;database=Northwind")
MyConn.Open()
Dim StrSelect As String = "Select * FROM Customers"
Dim SqlKu As SqlCommand = New SqlCommand(StrSelect, MyConn)
Dim MyReader As SqlDataReader
MyReader = SqlKu.ExecuteReader()
DataList1.DataSource = MyReader
DataList1.DataBind()
MyReader.Close()
MyConn.Close()
End Sub
There's nothing error occur.. just blank, please help me to fix it.
Is it with VS2005 we can write codes manually just like we do with VS2003?
Thanks.
.NET Framework 2.0 has a lot of new controls that cut down on the amount of code you have to write. Two things I recommend in the code you provided are to open the connection as late as possible and to use try / finally or try / catch / finally in your code.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyConn As SqlConnection = Nothing
Dim MyReader As SqlDataReader = Nothing
Try
MyConn = New SqlConnection("Server=localhost;UID=sa;PWD=;database=Northwind")
Dim StrSelect As String = "Select * FROM Customers"
Dim SqlKu As New SqlCommand(StrSelect, MyConn)
MyConn.Open()
MyReader = SqlKu.ExecuteReader()
DataList1.DataSource = MyReader
DataList1.DataBind()
Finally
If Not MyReader Is Nothing Then
If Not MyReader.IsClosed Then
MyReader.Close()
End If
End If
If Not MyConn Is Nothing Then
If MyConn.State = ConnectionState.Open Then
MyConn.Close()
End If
End If
End Try
End Sub
If the above code doesn't work, then there is some issue with your connection to the database or the query itself.
HTH,
Ryan
Hi,
another interesting read is this:Open() late, Close() early
Grz, Kris.
This Dataset is going to be the death of me! Please Help
ambigous: "System.NullReferenceException: Object reference not set to an
instance of an object." I have tried replacing the variable "month" with a
string and I tried replacing "ProductList.ToString()" with a string but I
still get the error:
Me.sqlDataAdapter1.Fill(DataSet1, "Queue")
Dim QueueRow As DataRow
QueueRow = DataSet1.Tables("Queue").Rows.Find(myCustomerID)
>>ERROR HERE<< QueueRow(month) = ProductList.ToString()
Me.sqlDataAdapter1.Update(DataSet1, "Queue")
Please Help!
Thanks, Justin.Justin wrote:
> (abridged) I have tried replacing the variable "month" with a
> string and I tried replacing "ProductList.ToString()" with a string but I
> still get the error:
What is the value of the month variable? It looks as if you're trying to
change the value of the "month" column in the DataRow. If so you must
place quotes around the word "month". Like this:
QueueRow("month") = ProductList.ToString()
Anders Nor?s
http://dotnetjunkies.com/weblog/anoras
month is a string variable representing a table column to save the data to, I
have tried replacing this with a static column string but I still get the
same error.
"Anders Nor?s" wrote:
> Justin wrote:
> > (abridged) I have tried replacing the variable "month" with a
> > string and I tried replacing "ProductList.ToString()" with a string but I
> > still get the error:
> What is the value of the month variable? It looks as if you're trying to
> change the value of the "month" column in the DataRow. If so you must
> place quotes around the word "month". Like this:
> QueueRow("month") = ProductList.ToString()
> Anders Nor?s
> http://dotnetjunkies.com/weblog/anoras
Justin wrote:
> month is a string variable representing a table column to save the data to, I
> have tried replacing this with a static column string but I still get the
> same error.
Ok, then I suspect that the statement
DataSet1.Tables("Queue").Rows.Find(myCustomerID) evaluates to null. If
this is the case, the ensuing statement will cause an
NullReferenceException. You can place an assertion in your code to
display a message if the QueueRow is null.
The following statement check whether QueueRow is null and outputs a
message if it is:
Debug.Assert( Not (QueueRow Is Nothing), "QueueRow parameter is null",
"Can't get object for null type")
Anders Nor?s
http://dotnetjunkies.com/weblog/anoras/
This Dataset is going to be the death of me! Please Help
ambigous: "System.NullReferenceException: Object reference not set to an
instance of an object." I have tried replacing the variable "month" with a
string and I tried replacing "ProductList.ToString()" with a string but I
still get the error:
Me.sqlDataAdapter1.Fill(DataSet1, "Queue")
Dim QueueRow As DataRow
QueueRow = DataSet1.Tables("Queue").Rows.Find(myCustomerID)
Me.sqlDataAdapter1.Update(DataSet1, "Queue")
Please Help!
Thanks, Justin.Justin wrote:
> (abridged) I have tried replacing the variable "month" with a
> string and I tried replacing "ProductList.ToString()" with a string but I
> still get the error:
What is the value of the month variable? It looks as if you're trying to
change the value of the "month" column in the DataRow. If so you must
place quotes around the word "month". Like this:
QueueRow("month") = ProductList.ToString()
Anders Nor?s
http://dotnetjunkies.com/weblog/anoras
month is a string variable representing a table column to save the data to,
I
have tried replacing this with a static column string but I still get the
same error.
"Anders Nor?s" wrote:
> Justin wrote:
> What is the value of the month variable? It looks as if you're trying to
> change the value of the "month" column in the DataRow. If so you must
> place quotes around the word "month". Like this:
> QueueRow("month") = ProductList.ToString()
> Anders Nor?s
> http://dotnetjunkies.com/weblog/anoras
>
Justin wrote:
> month is a string variable representing a table column to save the data to
, I
> have tried replacing this with a static column string but I still get the
> same error.
Ok, then I suspect that the statement
DataSet1.Tables("Queue").Rows.Find(myCustomerID) evaluates to null. If
this is the case, the ensuing statement will cause an
NullReferenceException. You can place an assertion in your code to
display a message if the QueueRow is null.
The following statement check whether QueueRow is null and outputs a
message if it is:
Debug.Assert( Not (QueueRow Is Nothing), "QueueRow parameter is null",
"Can't get object for null type")
Anders Nor?s
http://dotnetjunkies.com/weblog/anoras/
Saturday, March 24, 2012
This message has been blocked for your safety
attached the print screen and here is the complete code:
NetworkCredential network_credential = new
NetworkCredential("info@dotnet.itags.org.zatoor.com", "xxxxxx");
MailMessage mail_message = new MailMessage();
// SmtpClient smtp_client = new SmtpClient("localhost");
SmtpClient smtp_client = new SmtpClient("smtp.zatoor.com");
smtp_client.UseDefaultCredentials = false;
smtp_client.Port = 25;
smtp_client.Credentials = network_credential;
string html_message = null;
html_message = "<html>";
html_message += "<head>";
html_message += "<meta http-equiv=Content-Type
content='text/html; charset=windows-1252'>";
html_message += "</head>";
html_message += "<body>";
html_message += "Thank you for registering with zatoor.com
and welcome to the world of free classifieds. We hope you will enjoy using
our website.";
html_message += "<br>";
html_message += "<br><br>";
html_message += "zatoor.com Team";
html_message += "</body>";
html_message += "</html>";
mail_message.From = new MailAddress("info@dotnet.itags.org.zatoor.com",
"zatoor.com");
mail_message.To.Add(txtEmailAddress.Text);
mail_message.CC.Add("jrahma@dotnet.itags.org.yahoo.com");
// mail_message.Priority = MailPriority.High;
mail_message.IsBodyHtml = true;
mail_message.Subject = "welcome to zatoor.com";
mail_message.Body = html_message;
mail_message.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnFailure;
smtp_client.Send(mail_message);Have you tried to click on "Learn more" ?!!!
It looks like you are using a software (not sure if this is a server side
firewall software or if you try to read the message in a client) that
consider this as a potential threat. IMO your best is to look for support at
this third party product site as it looks like this issue is not related to
.NET...
Patrice
"Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
F12C8C18-20DE-4A06-A415-2FC181265544@.microsoft.com...
>I am getting this message when sending using System.Net.Mail... I have
> attached the print screen and here is the complete code:
> NetworkCredential network_credential = new
> NetworkCredential("info@.zatoor.com", "xxxxxx");
> MailMessage mail_message = new MailMessage();
> // SmtpClient smtp_client = new SmtpClient("localhost");
> SmtpClient smtp_client = new SmtpClient("smtp.zatoor.com");
> smtp_client.UseDefaultCredentials = false;
> smtp_client.Port = 25;
> smtp_client.Credentials = network_credential;
> string html_message = null;
> html_message = "<html>";
> html_message += "<head>";
> html_message += "<meta http-equiv=Content-Type
> content='text/html; charset=windows-1252'>";
> html_message += "</head>";
> html_message += "<body>";
> html_message += "Thank you for registering with zatoor.com
> and welcome to the world of free classifieds. We hope you will enjoy using
> our website.";
> html_message += "<br>";
> html_message += "<br><br>";
> html_message += "zatoor.com Team";
> html_message += "</body>";
> html_message += "</html>";
> mail_message.From = new MailAddress("info@.zatoor.com",
> "zatoor.com");
> mail_message.To.Add(txtEmailAddress.Text);
> mail_message.CC.Add("jrahma@.yahoo.com");
> // mail_message.Priority = MailPriority.High;
> mail_message.IsBodyHtml = true;
> mail_message.Subject = "welcome to zatoor.com";
> mail_message.Body = html_message;
> mail_message.DeliveryNotificationOptions =
> DeliveryNotificationOptions.OnFailure;
> smtp_client.Send(mail_message);
>
can you please expian what do you mean?
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:uKsNceTyHHA.4712@.TK2MSFTNGP04.phx.gbl...
> Have you tried to click on "Learn more" ?!!!
> It looks like you are using a software (not sure if this is a server side
> firewall software or if you try to read the message in a client) that
> consider this as a potential threat. IMO your best is to look for support
> at this third party product site as it looks like this issue is not
> related to .NET...
> --
> Patrice
> "Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
> F12C8C18-20DE-4A06-A415-2FC181265544@.microsoft.com...
>
AFAIK this message is not produced by the DOTNET framework but by a third
party product that blocks the message you try to send for some reason.. In
this message you have a "Learn more" link that you could click to see why
this third party software choosed to block this transmission.
So for now it looks like to me this is not at all related to a programming
issue but to a third party software (firewall, antivirus ?)
Or is this that your mail provider replaced the screenshot by a message of
its own ;-) - Generally just reproducing the text should be enough. The
message I see is the "This message has been blocked for your safety"" whih
is not a DOTNET message...
Patrice
"Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
uOjWFueyHHA.5380@.TK2MSFTNGP04.phx.gbl...
> can you please expian what do you mean?
>
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:uKsNceTyHHA.4712@.TK2MSFTNGP04.phx.gbl...
>
but I am not getting this problem when sending to yahoo address?!! it only
shows when sending to hotmail? any parameters I should set in order to make
the email trusted?
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:ey3I1qfyHHA.1176@.TK2MSFTNGP05.phx.gbl...
> AFAIK this message is not produced by the DOTNET framework but by a third
> party product that blocks the message you try to send for some reason.. In
> this message you have a "Learn more" link that you could click to see why
> this third party software choosed to block this transmission.
> So for now it looks like to me this is not at all related to a programming
> issue but to a third party software (firewall, antivirus ?)
> Or is this that your mail provider replaced the screenshot by a message of
> its own ;-) - Generally just reproducing the text should be enough. The
> message I see is the "This message has been blocked for your safety"" whih
> is not a DOTNET message...
> --
> Patrice
> "Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
> uOjWFueyHHA.5380@.TK2MSFTNGP04.phx.gbl...
>
Don't know. Once again for now it doesn't look to me this is a problem at
the DOTNET framework level.
Don't you have a window title or something that could tell you what is the
product that display this message ? Don't you know if this looks like
screens displayed by your antivirus, firewall software etc... Don't you see
a productname somewhere ?
"Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
35430664-840E-460A-ACEC-545E37C8A0A0@.microsoft.com...
> but I am not getting this problem when sending to yahoo address?!! it only
> shows when sending to hotmail? any parameters I should set in order to
> make the email trusted?
>
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:ey3I1qfyHHA.1176@.TK2MSFTNGP05.phx.gbl...
>
no, it dosn't show any name
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:OrUdNUsyHHA.1184@.TK2MSFTNGP04.phx.gbl...
> Don't know. Once again for now it doesn't look to me this is a problem at
> the DOTNET framework level.
> Don't you have a window title or something that could tell you what is the
> product that display this message ? Don't you know if this looks like
> screens displayed by your antivirus, firewall software etc... Don't you
> see a productname somewhere ?
> "Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
> 35430664-840E-460A-ACEC-545E37C8A0A0@.microsoft.com...
>
I gave this a look. It looks like you might as well have this when you read
this mail in hotmail ? What didn't you said that ?!
Click on Open Message to read the mail. Click On "Learn more" or the FAQ to
find out why Hotmail classified this message as potentially dangerous. For
example an option could simply black HTML mails (that could contains
JavaScript exploits) ?
So it looks like an hotmail issue. Nothing to do with DOTNET IMO.
Patrice
"Jassim Rahma" <jrahma@.hotmail.com> a crit dans le message de news:
FF331512-9F1A-49F6-AC24-6D2BBB39314B@.microsoft.com...
> no, it dosn't show any name
>
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:OrUdNUsyHHA.1184@.TK2MSFTNGP04.phx.gbl...
>
This really shouldn't have much code in it anyway
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
/* don't put logic here. only lines to call your logic elsewhere */
}
You should not business logic in your controls. You should
not put business logic (no matter how small) in your event
handling sections or even form methods.
You'll be much better off enhancing your application if
your business rules are in classes that are not tied directly
to your UI or business layers outside of the parameters
passed in.
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
<apandapion@dotnet.itags.org.gmail.com> wrote in message
news:1124130872.659013.20810@dotnet.itags.org.g47g2000cwa.googlegroups.com...
> I'm working with csharp and .net for the first time, and I've had a
> fair amount of luck. I started with the MSDN "Walkthrough : Creating a
> Distributed Application" tutorial and expanded from there, adding state
> management and other assorted things.
> So I have a lot of code that looks like this:
> private void DataGrid1_UpdateCommand(object source,
> System.Web.UI.WebControls.DataGridCommandEventArgs e)
> {
> /* snip lots of code that I've written */
> }
> It wraps a dataset obtained through a pretty standard two function
> GetTable/UpdateTable web service.
> I want to reuse this code, and not in the braindead
> cut/paste/alter/suffer manner. Under the .net architecture, what's the
> best way to go about it? Write my own class that inherits from
> DataGrid? I tried that, and it encapsulates the code nicely, but it
> also causes lots of errors from the aspx file that I'm not sure how to
> handle. Do I have to write a web custom control? Do I lose access to
> the designer in doing so?
>Morris, that's pretty much what I said. We agree on the theory. I'm
looking for a good way to reencapsulate the code, as in, "what language
construct should I use?" Inherit from DataGrid? Write a helper
object? Write my own macro preprocessor?
It's a little hard to encapsulate anything coming off of the XML soap
interface, as the objects are not objects but just a pair of get/put
function calls. And the ASPX side of my module seems to react very
strangely to me inheriting from DataGrid.
I had no trouble working out how to plug COM objects together, back in
the day, as life was just a matter of locating, implementing and
invoking interfaces. Dotnet is a lot easier to work with, so far, but
it's not abundantly clear how I'm supposed to both encapsulate my own
code and interact with the twisty maze of microsoft objects that I have
to talk to on all sides. I would like to think that dotnet is good for
more than toys, but I haven't seen real evidence of that so far.
Can you recommend some books, or technical articles, that demonstrate
the right way to do things? I don't want clouds with lines between
them... I want code. It would be nice to do things "the right way",
from the beginning, but right now I'm just a s
Thursday, March 22, 2012
thread being aborted?
Dim connstring As New SqlConnection("Server=kabunyawan\sqlexpress;Database=ojt;Trusted_Connection=True;")
Dim rs1 As New SqlDataAdapter("select * from wall where uname = '" & txtuname.Text & "' and pword = '" & txtpword.Text & "'", connstring)
Dim ds As New DataSet
Dim tmpStr As String
rs1.Fill(ds, "wall")
Try
tmpStr = ds.Tables("wall").Rows(0).Item("lvl")
If tmpStr = "admin" Then
Response.Redirect("contact.aspx")
Else
Response.Write(tmpStr)
Response.Write("admin")
Response.Write("1111111111111111")
End If
Catch ex As Exception
Response.Cookies("errmsg").Value = "Invalid username/password. Please contact the admins for assisstance."
Response.Redirect("merror.aspx")
End Try
End Sub
i am having error on response.redirect("contact.aspx").. but my other webforms are working..Problem Solved.. that error was caused by the "try-catch" part.. I've read that response.redirect will always give out an error if placed within a try-catch.. now i know!
Now read that Response.Write is a bad thing on ASP.NET pages. :)
Thread execution report?
send the newsletter I use a thread that sends all the newsletters, so that
when I write the newsletter I don't need to wait for all the mails to be
delivered, but it's the thread I launch that is responsible for the delivery
.
My question is, is there a way to have a report of the status of the deliver
y?
Since HTTP is stateless, I don't think there is a simple way to do this,
since, after I send the email and my request ends, I no longer have a way to
communicate with the thread which is still running on the server to send the
emails.
Do you have any suggestion?
Simone BusoliHave it send you an email.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Simone Busoli" <SimoneBusoli@.discussions.microsoft.com> wrote in message
news:B6C016E0-6099-4E60-9744-6BD7DEB0C06D@.microsoft.com...
> Hi, I am creating a newsletter system, and in the webform used to write
> and
> send the newsletter I use a thread that sends all the newsletters, so that
> when I write the newsletter I don't need to wait for all the mails to be
> delivered, but it's the thread I launch that is responsible for the
> delivery.
> My question is, is there a way to have a report of the status of the
> delivery?
> Since HTTP is stateless, I don't think there is a simple way to do this,
> since, after I send the email and my request ends, I no longer have a way
> to
> communicate with the thread which is still running on the server to send
> the
> emails.
> Do you have any suggestion?
> --
> Simone Busoli
Tuesday, March 13, 2012
Thread timeouts
I have web based email management system where a user can login, create an
email and then send it to multiple recipients.
The email component I use generates all of the physical .eml files when they
click send. When a user is sending to 120, 000 recipients at once the page
times out.
I was thinking of using a separate worker thread for creating the email
messages (I dont have to worry about sending because the files get put into
a pickup directory that gets read by an SMTP component). My main concern
is - would the thread timeout at all, when trying to generate so many files?
Thanks in advance
GrahamHi Graham:
Threads do not time out, so I wouldn't have this concern.
Applications can timeout, however. I can configure an application pool in
Win2003 to shut down an app after x minutes of inactivity. A background thre
ad
isn't considered activity though - only incoming requests are. Something
to look for in your config.
Scott
http://www.OdeToCode.com/blogs/scott/
> Hi,
> I have web based email management system where a user can login,
> create an
> email and then send it to multiple recipients.
> The email component I use generates all of the physical .eml files
> when they
> click send. When a user is sending to 120, 000 recipients at once the
> page
> times out.
> I was thinking of using a separate worker thread for creating the
> messages (I dont have to worry about sending because the files get put
> into
> a pickup directory that gets read by an SMTP component). My main
> concern
> is - would the thread timeout at all, when trying to generate so many
> files?
> Thanks in advance
> Graham
Thread timeouts
I have web based email management system where a user can login, create an
email and then send it to multiple recipients.
The email component I use generates all of the physical .eml files when they
click send. When a user is sending to 120, 000 recipients at once the page
times out.
I was thinking of using a separate worker thread for creating the email
messages (I dont have to worry about sending because the files get put into
a pickup directory that gets read by an SMTP component). My main concern
is - would the thread timeout at all, when trying to generate so many files?
Thanks in advance
GrahamHi Graham:
Threads do not time out, so I wouldn't have this concern.
Applications can timeout, however. I can configure an application pool in
Win2003 to shut down an app after x minutes of inactivity. A background thread
isn't considered activity though - only incoming requests are. Something
to look for in your config.
--
Scott
http://www.OdeToCode.com/blogs/scott/
> Hi,
> I have web based email management system where a user can login,
> create an
> email and then send it to multiple recipients.
> The email component I use generates all of the physical .eml files
> when they
> click send. When a user is sending to 120, 000 recipients at once the
> page
> times out.
> I was thinking of using a separate worker thread for creating the
> email
> messages (I dont have to worry about sending because the files get put
> into
> a pickup directory that gets read by an SMTP component). My main
> concern
> is - would the thread timeout at all, when trying to generate so many
> files?
> Thanks in advance
> Graham
Thread was being aborted
I am getting an exception
when i print e.message it is::'Thread was being aborted.'
e.stacktrace is:: at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse) at System.Web.HttpResponse.Redirect(String url) at EmailMessage.BtnSendMail_Click(Object sender, EventArgs e)'
what should i do?
Hey,
With your Response.Redirect statement, make it Response.Redirect("url destination", false);
Hi sujithukvl,
"thread was being aborted" is an known issue. you can find more detailed information by clicking the following links.
http://communityserver.org/forums/p/475527/556989.aspx
http://www.msdner.com/forum/thread261068.html
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic3899.aspx
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Thread was being aborted in Response.Redirect
"Thread was being aborted
at System.Threading.Thread.AbortInternal() at
System.Threading.Thread.Abort(Object stateInfo) at
System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String
url, Boolean endResponse) at ..."
It doesn't interfere with the functionality and is transparent, and the only
reason I know it is tripped is because I write the errors to a log.
I am doing some processing in my code-behind, and after processing simply
re-direct to the next page. Is there a proper way of ending things before
re-directing?
I have used the boolean parameter for ending the thread, but it seems to
have no effect.
Thanks,
gsk
http://www.meblogic.comthis is normal, Response.End() is implemented as a thread abort.
-- bruce (sqlwork.com)
"GSK" <gsk@.NiOcSaP.nAeMt> wrote in message
news:uAXMCCYTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> I am logging the following error when re-directing via Response.Redirect:
> "Thread was being aborted
> at System.Threading.Thread.AbortInternal() at
> System.Threading.Thread.Abort(Object stateInfo) at
> System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String
> url, Boolean endResponse) at ..."
> It doesn't interfere with the functionality and is transparent, and the
only
> reason I know it is tripped is because I write the errors to a log.
> I am doing some processing in my code-behind, and after processing simply
> re-direct to the next page. Is there a proper way of ending things before
> re-directing?
> I have used the boolean parameter for ending the thread, but it seems to
> have no effect.
> Thanks,
> gsk
> http://www.meblogic.com
>
>