|
Have you tried setting Stream.ReadTimeout? Not sure if it will help, but I think it should.
BTW: don't read Stream.ContentLength twice, defensive programming dictates you read it once and store it in a local variable. If it were to change, for whatever reason, your code could be in a lot of trouble.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.4
|
|
|
|
|
yes, thanks, that was the variable to set to, stream.TimeOut
by default it is 5 minutes to read and write, quite large value.
I would never discover the problem had it not been to wifi connection.
It is surprising that ordinary landline disconnection immediatly result in Read() failure but with wifi it waits entire timeout.
Чесноков
|
|
|
|
|
The is no way for TCP to recognize that the other end no longer exists when it is waiting for a response.
So the same is true for any protocol built on it.
There might be situations where some sort of exception results. Maybe. For example I am not sure what the windows IP stack might do if you pull your network cable.
But if you want to deal with all situations and not a just a few then you need to set up a timeout. Either via the protocol itself or via a secondary thread.
|
|
|
|
|
jschell wrote: But if you want to deal with all situations and not a just a few then you need
to set up a timeout. Either via the protocol itself or via a secondary thread
I do set timeout in web request but I do not know how to set it for Read() operation as it just blocks.
Чесноков
|
|
|
|
|
Hello,
Instead of on the aspx page, to have this code on the server side. Can we do this? Especially for the email check and decimals check? Like for the email check i have this set up on the page aspx, \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*? Can add it the same way on the server page, meaning .cs page?
Thanks!
|
|
|
|
|
Do you mean add a RegularExpressionValidator control to the page from the code-behind? If so then yes.
RegularExpressionValidator validator = new RegularExpressionValidator();
validator.ValidationExpression = "...";
Controls.Add(validator);
If you mean can you valid a string in the code-behind, then again yes.
Regex.IsMatch("pattern", stringToCheck);
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I tried Regex but it was not showing as an option. I will try using RegexStringValidator.
Thanks for your help in a timely manner!
|
|
|
|
|
vanikanc wrote: I tried Regex but it was not showing as an option
What are you talking about? Do you have the correct assemblies referenced? Do you place the correct using statement?
RegexStringValidator is not what you need to use. It will throw an exception if the string is not correct, very heavy handed and not recommended.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have
using System.Configuration;
anything else?
|
|
|
|
|
|
hello guys.. a basic question about inserting row in the sql server. I made all the necessary arrangements first (like creating a login then enabling it, changing the login mode to Mix-Mode). But following code is not working, I dont know what is the problem in the connection string
string connectionString = "Data Source=srv032k3; Initial Catalog=MuzeDB;Integrated Security=SSPI; User ID=sa; Password=;sa";
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM students ORDER BY Id", connection);
SqlCommandBuilder command = new SqlCommandBuilder(adapter);
DataSet ds = new DataSet("StudentsSet");
adapter.Fill(ds, "students");
DataTable dt = ds.Tables["students"];
DataRow row = dt.NewRow();
int id;
string name, address;
id = 4;
name = "Nadeem";
address = "Layya";
row["Id"] = id;
row["Name"] = name;
row["Address"] = address;
dt.Rows.Add(row);
adapter.Update(ds, "students");
Console.WriteLine("A new row added: {0} {1} {2}", id, name, address);
connection.Close();
}
catch (Exception ex)
{ Console.WriteLine(ex.Message); }
what can be the problem? thnx
|
|
|
|
|
Well, you have password=;sa . That's the problem - the ; tells it that you have an empty password, and then the sa creates a malformed connection string.
|
|
|
|
|
I did what you suggested but it is not working (using a different login). Here is modified connection string
string ConnectionString = "Data Source=srv032k3;Initial Catalog=MuzeDB;Integrated Security=SSPI; User ID=muze; Password=saeedasd;";
|
|
|
|
|
As you have a user name and password, you need to remove Integrated Security=SSPI; . It's one or the other, not both.
|
|
|
|
|
Hi,
Try to remove Integrated Security=SSPI; from your connection string. You are trying to use two connection methods at the same time (SSPI means you're trying to authenticate as the calling user, and you provide other authentification information at the same time).
Moreover, it's a very bad design to authenticate as 'sa' in your code ; better create a connection in your SQL instance matching your user login, and give it the roles you want on the database(s) you want. Then you'll be able to use Integrated Security=SSPI; , without supplying UserId and Password information in your connection string.
|
|
|
|
|
I did what you suggested but it is not working. Here is modified connection string
string ConnectionString = "Data Source=srv032k3;Initial Catalog=MuzeDB;Integrated Security=SSPI; User ID=muze; Password=saeedasd;";
|
|
|
|
|
No you didn't. Read carefully and you will get it.
|
|
|
|
|
Yes. I did it. I actually made a new login and then tried to used that connection string. Does this mean that either I should use Integrated Security or I the User ID, Password methodology?
|
|
|
|
|
Yes, it is exactly what that means
|
|
|
|
|
Try
string connectionString = "Data Source=srv032k3; Initial Catalog=MuzeDB; User ID=sa; Password=YourPassword";
take a look there[^]
for more information.
|
|
|
|
|
You're also creating an adapter from a select statement. Is it possible to insert through that? That seems a bit weird to me.
|
|
|
|
|
Yes. I have done it. It adds a new row and it also selects all records from the table and puts them into the dataset.
|
|
|
|
|
hello everyone,
I want to calculate the total data download and upload in a particular interval of time, and store it to a database so that it can be viewed later on. data downloaded from internet
browser or uploaded using default downloader and i want to store info - size and time
info. is it possible through system.diagnostics namespace........
thank you for any help...........
|
|
|
|
|
I have created an XML using sql in SQL Server 2005.
I like to Save that XML as a File in a particular location on the disk.
I want only C# to make it done...
It would not be possible to create that file on the disk using SQL Server becoz,
I haven't administrator permission for the Sql Server.
if i use DataReader to get field value, than it's not return complete xml...
what i have to do...?
|
|
|
|
|