|
Use SQLServerCe file based database.
If you insist on a text file an indexed flat file will be the fastest.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
If you want efficiency, the Dictionary (which is based on a hash table) is the best choice. Databases are slow and a bit more complex.
|
|
|
|
|
Hi all. I'm having a slight problem. I'm trying to write a method for performing HTTP GET and POST requests. It all works fine, but the problem I'm having is that the request gets sent without the parameters I've passed. The server then responds, and only then are the parameters sent. In one particular case, I'm trying to replicate the request in my application that is sent by internet explorer. In internet explorer, the headers and parameters are sent as a single request.
I used a packet sniffer to see what was going on.
In my application, this is the first frame sent:
http://img511.imageshack.us/img511/921/appframe1ag8.jpg
This is the second frame sent:
http://img511.imageshack.us/img511/8359/appframe2zy4.jpg
In comparison, this is the single frame sent in internet explorer (note that the payload at the bottom is combined as part of the request, which is what I want to achieve):
http://img514.imageshack.us/img514/8342/ieframe1fr7.jpg
My code is as follows:
/// <summary> | /// Performs an HTTP request | /// </summary> | /// <param name="uri">Uniform resource identifier</param> | /// <param name="method">HTTP request method (GET/POST)</param> | /// <param name="parameters">HTTP POST request parameters (example: "name1=value1&name2=value2")</param> | /// <param name="referer">Referer HTTP header URI</param> | /// <returns>Returns the server's response</returns> | public string HTTP_Request(string uri, string method, string parameters, string referer) | { | // Create a WebRequest object | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | // Set request properties | request.Method = method; | request.ContentType = @"application/x-www-form-urlencoded"; | request.CookieContainer = cookies; | request.KeepAlive = true; | request.Referer = referer; | request.UserAgent = @"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Win64; x64; .NET CLR 2.0.50727; SLCC1; Media Center PC 5.0;" + | ".NET CLR 3.5.30729; .NET CLR 3.0.30618"; | request.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, " + | "application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, */*"; | // If the HTTP request method is POST, send parameters to the server | if (method == "POST") | { | byte[] buffer = Encoding.UTF8.GetBytes(parameters); | Stream dataStream = null; | try | { | // Set the content length of the request data being sent | request.ContentLength = buffer.Length; | // Retrieve Stream object for writing data | dataStream = request.GetRequestStream(); | // Send data | dataStream.Write(buffer, 0, buffer.Length); | } | catch (Exception) | { | MessageBox.Show("HTTP_Request Error:\n\nRequest error"); | } | finally | { | if (dataStream != null) | dataStream.Close(); | } | } | // Get the HTTP request response | HttpWebResponse response = null; | StreamReader reader = null; | try | { | // Retrieve HttpWebResponse object containing the server's response | response = (HttpWebResponse)request.GetResponse(); | // Retrieve StreamReader object for reading data | reader = new StreamReader(response.GetResponseStream()); | // Return the trimmed server response | return reader.ReadToEnd().Trim(); | } | catch (Exception) | { | MessageBox.Show("HTTP_Request Error:\n\nResponse error"); | } | finally | { | if (response != null) | response.Close(); | if (reader != null) | reader.Close(); | } | return null; | } |
|
|
|
|
|
IIRC you need a new line after the parameters.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
You can also look at the HttpWebRequest.SendChunked property.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hello I am a C++ developer but I would like to see the doability of something :
indeed I saw that many thirdparty controls can be installed and added to VC.Net and they will appear
in the Toolbox so developers can just drag and drop them into the Forms editor.
In MFC this does not exist.
I also saw that it is possible using the "smart tag" to apply certain properties and see the effect in place, so it is not a simple image or static area.
I'd like to understand how is that possible.
I suppose to download the VS SDK to be able to do that thing, no ?
Is there something in action I can see it and learn from it ??
Thank you in advance.
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
Hi,
thanks in advance for your answers.
I realized a windows service by c# where exceptions are managed.
This service run continously for more than 1 month on server machine with Windows Server 2003 (Service Pack 1). However the service crashed. When an exception arrive I log it in a text file, but in this case I didn't write anything.
In windows event viewer I found this error:
Tipo evento: Errore
Origine evento: .NET Runtime 2.0 Error Reporting
Categoria evento: Nessuno
ID evento: 1000
Data: 14/11/2008
Ora: 14.53.29
Utente: N/D
Computer: DATASERVERR2
Descrizione:
Faulting application srvcconnettore.exe, version 1.0.0.0, stamp 49007432, faulting module kernel32.dll, version 5.2.3790.2919, stamp 462648c6, debug? 0, fault address 0x00015e02.
Per ulteriori informazioni, consultare la Guida in linea e supporto tecnico all'indirizzo http://go.microsoft.com/fwlink/events.asp.
Dati:
0000: 41 00 70 00 70 00 6c 00 A.p.p.l.
0008: 69 00 63 00 61 00 74 00 i.c.a.t.
0010: 69 00 6f 00 6e 00 20 00 i.o.n. .
0018: 46 00 61 00 69 00 6c 00 F.a.i.l.
0020: 75 00 72 00 65 00 20 00 u.r.e. .
0028: 20 00 73 00 72 00 76 00 .s.r.v.
0030: 63 00 63 00 6f 00 6e 00 c.c.o.n.
0038: 6e 00 65 00 74 00 74 00 n.e.t.t.
0040: 6f 00 72 00 65 00 2e 00 o.r.e...
0048: 65 00 78 00 65 00 20 00 e.x.e. .
0050: 31 00 2e 00 30 00 2e 00 1...0...
0058: 30 00 2e 00 30 00 20 00 0...0. .
0060: 34 00 39 00 30 00 30 00 4.9.0.0.
0068: 37 00 34 00 33 00 32 00 7.4.3.2.
0070: 20 00 69 00 6e 00 20 00 .i.n. .
0078: 6b 00 65 00 72 00 6e 00 k.e.r.n.
0080: 65 00 6c 00 33 00 32 00 e.l.3.2.
0088: 2e 00 64 00 6c 00 6c 00 ..d.l.l.
0090: 20 00 35 00 2e 00 32 00 .5...2.
0098: 2e 00 33 00 37 00 39 00 ..3.7.9.
00a0: 30 00 2e 00 32 00 39 00 0...2.9.
00a8: 31 00 39 00 20 00 34 00 1.9. .4.
00b0: 36 00 32 00 36 00 34 00 6.2.6.4.
00b8: 38 00 63 00 36 00 20 00 8.c.6. .
00c0: 66 00 44 00 65 00 62 00 f.D.e.b.
00c8: 75 00 67 00 20 00 30 00 u.g. .0.
00d0: 20 00 61 00 74 00 20 00 .a.t. .
00d8: 6f 00 66 00 66 00 73 00 o.f.f.s.
00e0: 65 00 74 00 20 00 30 00 e.t. .0.
00e8: 30 00 30 00 31 00 35 00 0.0.1.5.
00f0: 65 00 30 00 32 00 0d 00 e.0.2...
00f8: 0a 00 ..
Could you give me a solution to this problem? Thank you!
|
|
|
|
|
Did you install any updates lately? To windows 2003 or any software around? I remember about sum of these issues with Symantec software.
Code? Yeah i love it fried together with a glass of wine.
|
|
|
|
|
Hi,
thanks for your answer. I didn't install any updates. Now I restarted my service and it's working correctly.
Have you any ideas?
|
|
|
|
|
I have developed a C# project which includes a text area and few other items
And I tried to play a background music using a thread.
The program works fine in my home machine,.
But once i tried to run it on different machine, an error occurs,.
So I copied the entire project and I tried to run it on another machine.(That machine had Visual Studio 2005),
And it gave and an error and said that the music file is not accessible.....
But it was there...
Is there a reason for this.
And I've heard that there is a method to include the files(media files, and pictures) into the project so that at the end(after compiling) you just need to carry the .exe, Not .exe file and the other files in its folder.
This would be a great help if any one can help ,me!!!
|
|
|
|
|
Hi,
you could try to add the music file as "Embedded resource" into your project. Than it will be "placed" inside the .exe-file. But accessing the file is different from accessing it as a file on a disk. You have to use something like:
<br />
Stream ioStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNamespace.MySoundfile.wav");<br />
Have a look here http://support.microsoft.com/kb/319292[^]
Hope this helps.
Regards Sebastian
|
|
|
|
|
Thank You very much Sebastian!!!
Thanks for the reply you have given,......
But I still have a small problem, To play the music I have used the
quartz.dll as a reference,
If so how am I gonna use this RESOURCE syntax...
|
|
|
|
|
Hmm, depends on the default namespace of your application.
It should look like:
"MyDefaultNamespace.quartz.dll"
To get the default namespace, open the project settings and navigate to the Application tab.
|
|
|
|
|
i have the following code - what it should do is to retrieve the rows that have the same id but the content within the other columns are not the same.
sqlquery = "select * from " + Table2 + " where " + txt_comkey_tbl2.Text + " in (select " + txt_comkey_tbl1.Text + " from " + Table1 + ")";
dbCmd = new OleDbCommand();
dbCmd.Connection = dbConn;
dbCmd.CommandText = sqlquery;
dbCmd.CommandType = CommandType.Text;
db1Reader = dbCmd.ExecuteReader();
dp = new DataSet();
db1table = dp.Tables.Add(sqlquery);
for (j = 0; j < dbReader.FieldCount; j++)
db1table.Columns.Add(db1Reader.GetName(j), db1Reader.GetFieldType(j));
foreach (DataRow dr in db1table.Rows)
{
for (int i = 0; i < db1table.Rows.Count; i++)
{
if (dr["Name"].ToString() == db1table.Rows[i]["Name"].ToString())
{
if (dr["Value"].ToString() != db1table.Rows[i]["Value"].ToString())
{
// select the row from the database and display in the grid...
}
}
}
}
however when i run the code i don't get any values on the datarow but execute the same sqlquery in the database two rows are returned. is there perharps something that is not done correctly?????
|
|
|
|
|
Hi Melanie,
is the sqlquery-text correct (I mean are the values you are using correct).
Next question I have i, why aren't you using the db1Reader like this:
<br />
while(db1Reader.Read()) {<br />
<br />
}<br />
I don't see the point where you putting the Values from the db1Reader into the db1table. So I assume that db1table has no rows...
Hope this helps.
Regards
Sebastian
|
|
|
|
|
Aside from the other post, you really need to not build SQL queries like that. You're very prone to someone injecting something that would compromise the system.
Do some searches on articles here at CodeProject regarding SQL Injection to find some tips on how to resolve the above issues.
|
|
|
|
|
You can use controls in a loop using FindControl(string name) (self made method).
However i would like do a loop with objects like:
string str1 = "test"
string str2 = "test"
string str3 = "test"
for (int i = 0; i < 5; i++)
{
str[i].Text = "test2";
}
Also tryed:
string new = (string)str[i];
Also didn't work.
Any idea/methods for doing something like this?
Thanks
|
|
|
|
|
No, you can't create a few objects named like this and then try and iterate through them like they are in an array.
Either add them to a collection, and iterate through that:
String str1 = "test";
String str2 = "test";
String str3 = "test";
List<string> strings1 = new List<string>();
strings1.Add(str1);
strings1.Add(str2);
strings1.Add(str3);
for (int i = 0; i < 3; i++)
{
strings1[i] = "test2";
}</string></string> Or create an array of them to begin with:
String[] strings2 = new String[3];
strings2[0] = "test";
strings2[1] = "test";
strings2[2] = "test";
for (int i = 0; i < 3; i++)
{
strings2[i] = "test2";
}
Simon
|
|
|
|
|
Aha yes i figured as much.
Thanks anyway.
|
|
|
|
|
Hi,
I have upload an image in to image column but i have no idea to get it from DB and displaying it in Image control or Bitmap.Is it possible to display?Then plz guide me...
|
|
|
|
|
|
Hi
Thanx for that link but it uses file to store and retrieve.Is it same for database retrieval.And also i want that image to display in some specific area of my page .
|
|
|
|
|
It stores data in database. In order to show it on form you can use Image.FromStream method to construct the image after you read data from database in stream.
|
|
|
|
|
K thanks i will check it out...
|
|
|
|
|
do you what to display images store in a database? search here in codeproject for samples. If you get stuck in debuging or for something else ask here, we help.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|