|
wsamuel,
"ProductsPerPage" is obviously null.
Line 25: productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);
Its got nothing to do with the database. I am sure you posted something VERY similar a week or so go, but was for different line, but the same error...
Regards,
Gareth.
|
|
|
|
|
Server Error in '/MemberPhoto' Application.
--------------------------------------------------------------------------------
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
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.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I've got another error for my program. This is obvious because of the connection problem. May i know more precisely what is going on?
|
|
|
|
|
wsamuel,
Well, firstly you should check:
When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
And also your connection string.
Regards,
Gareth.
|
|
|
|
|
Should i instead check on my coding or check on the connection setup? Is there any tutorial or sample showing how to configure the connection?
|
|
|
|
|
Gareth is right. The error message gives you a clue. By default a SQL Server 2005 database only allows connections that originate from applications running on the same database server. You need to the change the Remote Connections settings in the SQL Server 2005 Surface Area Configuration. You'll see that the default is local connections only. You need to change to local and remote connections and pick one of the sub-options.
Can we have a look at the connection string?
|
|
|
|
|
ya sure..
// creates and prepares a new DbCommand object on a new connection
public static DbCommand CreateCommand()
{
// Obtain the database provider name
string dataProviderName = MemberPhotoConfiguration.DbProviderName;
// Obtain the database connection string
string connectionString = MemberPhotoConfiguration.DbConnectionString;
// Create a new data provider factory
DbProviderFactory factory = DbProviderFactories.GetFactory(dataProviderName);
// Obtain a database specific connection object
DbConnection conn = factory.CreateConnection();
// Set the connection string
conn.ConnectionString = connectionString;
// Create a database specific command object
DbCommand comm = conn.CreateCommand();
// Set the command type to stored procedure
comm.CommandType = CommandType.StoredProcedure;
// Return the initialized command object
return comm;
}
Does this means it's the problem with the configuration? I have try the method you recommended by changing the setting but it still didn't work. Is there any other solution for this? Thx!
modified on Sunday, March 30, 2008 10:16 AM
|
|
|
|
|
Dear guru's
I have data-files with some structure in it. These files a continuously read/modified/written/extended/read/.....
Now I have a problem. What happens if just during writing such a file a computer-crash happens? My files are corrupted and the next read-operation will fail.
Two questions:
1.
I know, this is a "standard"-problem which is already solved. Can somebody give me any hint/link to a solution?
2.
This is not directly related to my question.
How can I ensure with .net, that a file is really physically written to hard-disk and not contained in any cache.
Thank you for your help
|
|
|
|
|
Frygreen wrote:
1.
I know, this is a "standard"-problem which is already solved. Can somebody give me any hint/link to a solution?
You may want to keep a temporary file on disk that will be autosaved during the execution of the program. When saving the actual file, you might just copy the temporary file over.
Frygreen wrote: 2.
This is not directly related to my question.
How can I ensure with .net, that a file is really physically written to hard-disk and not contained in any cache.
As far as I know calling Close on a stream will cause the data to be flushed. If you don't want to close the file operation, you may call Flush explicitly.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Frygreen wrote: a computer-crash happens
What u mean by Crash? electricity power is off for example
If so, I think you need to close the file and reopen it betwen different operations
Mohammed Gouda
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
yes, by "crash" I mean electric power off.
But even closing and opening does not help a lot, because it can happen that just the last "closing"-operation causes trouble
|
|
|
|
|
Hello!
I am writing an application that works with a SQL Server database,
and in the application I try to run a query which has a dash ('-')
in it. Because of the dash, the query doesn't work.
I guess that the .net compiler understands the dash as a special
character, and sends the wrong query to SQL Server.
Is it right? Or the problem is not this?
How can I solve it?
Thanks!
|
|
|
|
|
Yevgeny Efter,
Post the SQL and maybe we can see why its not working.
Regards,
Gareth.
|
|
|
|
|
Yevgeny Efter wrote: a query which has a dash ('-')
in it. Because of the dash, the query doesn't work.
I guess that the .net compiler understands the dash as a special
character, and sends the wrong query to SQL Server.
Is it right? Or the problem is not this?
The C# compiler (.NET is the framework) will not change your query. So, no, that is not right.
Most likely the SQL code supplied is not legal SQL in the first place.
Yevgeny Efter wrote: How can I solve it?
Since we have no idea of what you have actually written it is difficult to say. There are a number of possibilities but they all depend on where this dash is and why it is there.
For example, is the dash in a column or table name? If so then escape it with square brackets e.g. [my-column-name-with-dashes]
|
|
|
|
|
Thank you! The brackets solved it.
Have a nice day!
|
|
|
|
|
I am using this code to save image...
System.Drawing.Bitmap bi = new System.Drawing.Bitmap(panel1.Width, panel1.Height);<br />
panel1.DrawToBitmap(bi, new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));<br />
bi.Save(@"c:\Bcodetest.jpeg", ImageFormat.Jpeg);
This code running successfully but i want that user can define his own path where he wants to save image how can i do that...
i am using savefiledialog to do that but i am unable to do that...
|
|
|
|
|
Hi,
show the code you tried and be specific about how it failed.
or read the documentation.
or look at one of many CP articles that are bound to use SaveFileDialog...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
|
Hi,
you failed to state what the problem is.
I do have some suggestions for you:
1. ShowDialog() returns a DialogResult, you should check it, and do nothing
when the user cancels.
2. SaveFileDialog class has a public Dispose method, you MUST call it when done;
one way of doing it correctly is with a using statement.
3. OpenFile() returns a stream, which you don't really need. Better use FileName
instead.
4.
Typically file extensions use lower-case, so ".Jpeg" is a bit peculiar. Also
a lot of JPEG files use ".jpg"
5.
You always save in JPEG format, but also accept ".bmp" and ".gif" extensions;
it does not look like a good idea to store a JPEG format in those.
6.
when folder is a string, folder.ToString() does not make sense, just use folder.
7.
Your folder strategy is weird: you come up with a folder value for each image;
if your program runs fast enough two or more images will end up in the same
folder, but when your PC is loaded somehow, they all may use different folders...
You may want to read my timers article.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Sir,
My problem is when i save image image then it save the file but it does not contain any thing means blank file is saved...
now i have made certain changes..
SaveFileDialog slv = new SaveFileDialog();<br />
slv.DefaultExt = "Jpeg";<br />
slv.FileName = DateTime.UtcNow.Ticks.ToString();<br />
slv.Filter = "Jpeg Images|*.jpg|Bmp Images|*.bmp|Gif Images|*.gif";<br />
slv.FilterIndex = 2;<br />
slv.Title = "Save images";<br />
slv.RestoreDirectory = true;<br />
slv.ShowDialog();<br />
System.IO.FileStream fs = (System.IO.FileStream)slv.OpenFile();<br />
for (int I = 0; I < listBoxtextfile.Items.Count; I++)<br />
{<br />
labelBcode.Text = "*" + listBoxtextfile.Items[I].ToString() + "*";<br />
labelBtext.Text = listBoxtextfile.Items[I].ToString();<br />
System.Drawing.Bitmap bi = new System.Drawing.Bitmap(panel1.Width, panel1.Height);<br />
panel1.DrawToBitmap(bi, new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));<br />
bi.Save(slv.OpenFile(), ImageFormat.Jpeg);<br />
bi.Dispose();<br />
} <br />
fs.Close();
|
|
|
|
|
Hi,
you used a stream, that you did not close and did not dispose of.
Reread my previous reply and follow all my suggestions!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
filestream that i have used that is already closed....
now i use dispose method to dispose savefiledialog but still it does not save image it just save blank image...
as i want to save image of panel control that is written in my code...
SaveFileDialog slv = new SaveFileDialog();
slv.DefaultExt = "Jpeg";
slv.FileName = DateTime.UtcNow.Ticks.ToString();
slv.Filter = "Jpeg Images|*.jpg|Bmp Images|*.bmp|Gif Images|*.gif";
slv.FilterIndex = 2;
slv.Title = "Save an Image File";
slv.RestoreDirectory = true;
slv.ShowDialog();
System.IO.FileStream fs = (System.IO.FileStream)slv.OpenFile();
System.Drawing.Bitmap bi = new System.Drawing.Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bi, new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));
bi.Save(slv.OpenFile(), ImageFormat.Jpeg);
bi.Dispose();
slv.Dispose();
fs.Close();
|
|
|
|
|
SaveFileDialog has a FileName property. You can use this to get the filename that the user has selected from the dialog.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi there,
i showed a print dialog before printing to set printing range but when it showed all were disabled... except of "All Pages"
is this problem occuring by printer or .net framework?
my printer is HP 1020 plus
any idea to solve this problem?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi,
I suggest you read the documentation on PrintDialog Properties; they are ordered
alphabetically and you are lucky, what you need is at the beginning...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
oh yeah, i got it, thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|