|
Thanks heaps, that worked a treat!
You ripper, would've taken me ages to work that out.
You beauty!
|
|
|
|
|
Hi!
How does one retrive the IP-address of the remote host? I can only retrive the AddressFamily, and can´t find out how i retrive the address. Can I get the IPEndPoint for the remote host in some way??
søren christensen
|
|
|
|
|
Allow me to answer my own question. To retrive the IP-address og the remote host you can call RemoteEndPoint on the Socket connection, which you the call ToString() on to get IP and port number.
<br />
Socket con = Server.Accept();<br />
<br />
Console.WriteLine( con.RemoteEndPoint.ToString() );<br />
s-christensen
|
|
|
|
|
Hello,
I have been looking at some boooks today to trynd find an example of displaying a bitmap on the screen and I found code hat did not help just give me errors.
How would I draw 'me.gif' on the screen in C# using GDi+?
I would really like your help! ;);P
Cheers,
Rob
|
|
|
|
|
You can draw it on a form using the Graphics.DrawImage() method:
Graphics g = this.CreateGraphics();
g.DrawImage(bmp,new Point(0,0));
HTH
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hello,
I have a project that uses a MDB file for it’s data. I am trying to make a setup and deployment project to install it the problem I am having is the path in the Crystal Report is seems to be hard coded from the wizard. I want it to use the path the exe is running when I try to set this in the IDE it throws a error. Is there a way to have the setup and deployment project set the path for this or is their a way I can do it?
Thanks for any help.
|
|
|
|
|
This isn't the responsibility of an install. The Crystal Report should be programmatically directed to the MDB by the program. If you're using the managed interfaces for Crystal Reports, you can use an OLE DB connection to the MDB file in your EXE's path (easy to get). Query something to generate a DataSet or something, then call ReportDocument.SetDataSource .
Besides, to set the path to the MDB in an install, you would have to write a custom action that actually changes the binary RPT file format, which isn't documented (to my knowledge). This is a proprietary format.
In any case, this is the responsibility of the program that displays the report. There are ways to programmatically set the report's data source at run-time and that is what should be done.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks but I must be missing somthing. I am trying to learn crystal and have a hard time. It seems to me in order to use reportdocument, I have to use reportdocument.load and I need to provide this a path and that will put me with the problem I started with. I have a report file already made.
|
|
|
|
|
Never mind I got it. Like I said a bot slow
|
|
|
|
|
I have created a service in C#.
The service loads a COM dll (it uses OLE DB classes) on startup which handles the database
connectivity part (SQL server).
When I startup the service it works fine for a local database but when the database is
remote the Open fails with an error.
The exception that is written into the Event Log is as follows:
"[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
"System.Runtime.InteropServices.COMException (0x80004005): [DBNETLIB][ConnectionOpen
(Connect()).]SQL Server does not exist or access denied.
To zero-in on the problem I ported the Database related code into a separate exe and found
that it works fine. SO this problem seems specific to a Service.
I am running the service logged is as a System Administrator and given full access to it at
the Remote server.
Has anybody faced this problem before. Pls help.
Coding is injurious to health!!
|
|
|
|
|
1. If you're connecting only to SQL Server and not any other DB systems, use the System.Data.SqlClient instead of OLE DB. These are classes written specifically for SQL Server with a lot of optimizations and additional features over OLE DB.
2. The problem seems to be security. When you put it in a Windows app, it runs under your user credentials (be default). If you are using SSPI to connect to the SQL Server with a trusted connection, your credentials are authenticated and authorized by SQL Server, so you're app can access it.
Typically, most Windows Services use the LocalSystem account. If your connection string is using SSPI and the LocalSystem (SYSTEM) account is NOT added to SQL Server as a viable user that can access the system, you'll get Access Denied.
You should either use a fixed User ID and Password in the connection string, as well as Trusted Connection. Or, continue to use Integrated Security=SSPI and add the SYSTEM account to SQL Server for that database and grant it the rights necessary to run (I wouldn't recommend making it a dbo, though).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Good advice Heath,
One more thing to add, is that if your service and SQL Server are on different boxes then you can't use or add System to an authorized account on SQL Server. Local System, uses a null user and null password to make autorization attempts against remote resources, unless you have null session shares turned on (NEVER DO THIS) it won't work.
You're best be is to create a domain account for your service, configure your service to run under this account and add this account to your sql server as a login and a user in your database.
If you do not have a domain, then as long as the same account exists on both boxes and has the same password you can still connect.
|
|
|
|
|
Did you actually read his question?
Heath Stewart wrote:
1. If you're connecting only to SQL Server and not any other DB systems, use the System.Data.SqlClient instead of OLE DB. These are classes written specifically for SQL Server with a lot of optimizations and additional features over OLE DB.
His data access is being done from a COM dll, not a .NET component. You are answering the wrong question.
Heath Stewart wrote:
Typically, most Windows Services use the LocalSystem account. If your connection string is using SSPI and the LocalSystem (SYSTEM) account is NOT added to SQL Server as a viable user that can access the system, you'll get Access Denied.
He is very clear about the fact that he is _not_ running the service under LocalSystem.
Heath Stewart wrote:
Typically, most Windows Services use the LocalSystem account. If your connection string is using SSPI and the LocalSystem (SYSTEM) account is NOT added to SQL Server as a viable user that can access the system, you'll get Access Denied.
He's also very clear that the database is on a remote machine, in which case granting LocalSystem access won't help at all because they are two unrelated LocalSystem accounts.
Heath Stewart wrote:
You should either use a fixed User ID and Password in the connection string, as well as Trusted Connection
*sigh* I'm not even going to go there.
Fortunately Terry's answer already homes in on what is likely the real problem.
-Blake
|
|
|
|
|
I have written a socket server that accepts a connection over a single port. It now reads data into a string and then creates a hipaa compliant file out of the data. That data is then sent to the mainframe and a response file is created. I then reverse the process and write the data back over the port to the sender. Right now the process is single threaded. Where I get the data, create file, wait for response file, send data. I can do all this in about 3-4 seconds.
I have a few questions that I hope someone can answer...
I need to address multiple request that are sent. How do I thread this process so that multiple transactions (data files) can be dealt with. I am concerned about the sender sending me a data feed that contains multiple data files like this
|data1|data2|data3|. How can I know where one piece of data starts and stops. Can I use a delimitor, the data file always ends in a ~ ?
Can I send and receive over 1 socket at the same time?
Should I leave the connection open all the time, or close it with each transmission? The client will be connected over a frame relay.
Any resources? I have found several examples where the connections are threaded, but I will only have 1 connection.
I really need to get my brain around the model for this process and can not seem to do it...
rod
|
|
|
|
|
I'm not sure I follow what you mean by threading. First, you mention a case where you want clients processed in multiple threads, but then you mention a single client processing multiple chunks of data. Could you elaborate a little on which you mean?
As far as handling multiple connections, there are a slew of articles here on CP about that so, unless necessary, I won't bog-down the forums with code.
If you want to handle multiple data chunks in a single transaction, think about how several protocols like HTTP deal with it: content-length. You should specify a protocol where the content-length is a fixed size, like a long . That gives the number of raw bytes to read. Read that many bytes. If data exists after that, assume it was another content-length. Keep doing the same thing. Of course, you'll want to check the input data to make sure the protocol was use correctly. This is pretty common in a lot of different things.
You can send and receive on the same socket in a connection protocol. There's some other stuff that has to be done with connectionless protocols since they send datagrams with no return.
As far as leaving the connection open, it really depends on the persistence of communication. If the transactions happen in intervals, you could get away with leaving the connection open. If they transactions are random or you're unsure if another transaction will occur, close the connection.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I'll add another vote for the general solution that Heath already sketched out. In addition, here[^] is some sample code to do exactly this which I posted last week in answer to someone else's question.
To answer your other questions:
Yes, you can read and write on the same socket at the same time.
Leave the connection open, a single connection doesn't consume enough resources to care about. You should, however, be prepared to handle connection failures and go back into listening state to wait for the client to reconnect, incase of transient network failure.
No, you don't need to use multiple threads given that you have a single client. (There is an advanced case where it might be useful to use multiple threads with one client, if you want to send your requests to the mainframe asynchronously, i.e. submit a second request before the result of the first one has been recieved. If your transactional performance is already adequate, then don't complicate life by doing that.)
One last pointer, checksums are your friend:
System.Convert.ToBase64String(<br />
System.Security.Cryptography.SHA1.Create().ComputeHash(<br />
System.Text.Encoding.Unicode.GetBytes(yourData)))
-Blake
|
|
|
|
|
|
I replied only stating that we've had the same, unresolved problem in a different manner indirectly with CDO.
But you're right, the COM forum is dead! I usually try to hop on by and answer a few questions now and then, but mostly some answers require code. Therein likes the problem! Posting sample C/C++ code takes many more lines than various .NET languages (sans MC++, of course!).
I still wonder what happened to friends of COM like Mike Dunn? Nick Parker here at work mentioned he works for PressPlay/Napster now.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi...
i made a windows form program...using C#...
this is what i wrote...
using System.Threading;<br />
using System.Windows.Forms;<br />
<br />
class ShowForm<br />
{<br />
public static void Main()<br />
{<br />
Form form = new Form();<br />
<br />
form.Show();<br />
<br />
Thread.Sleep(2500);<br />
<br />
form.Text = "My first Form!";<br />
<br />
Thread.Sleep(2500);<br />
}<br />
} now what happens is a command console apprears then the window appears since i didnt write anything to keep the window there it dissapears..(which is ok,,cause i intended so)
after the window goes off, the console still remains saying
Press any key to continue...
is that supposed to happen??isn't that awkward???is there a way so that the console doesn't come up??
tks for the help....
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
On your project properties, change to "Output Type" from "Console Application" to "Windows Application".
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|
|
tks a lot...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
"(null)" values in datagrid - how to avoid it? (in datagrid or dataset)
One solution is to change SQL query (i.e. NVL function), but it's not comfortable and I don't want to get the solution this way.
Many thanks for answer in advance.
misiek
|
|
|
|
|
You can change your dataset so it automatically changes null for, e.g., an empty string. Every dataset column has the "NullValue" property, check it on the dataset designer by clicking on a string column and pressing F4 to bring up the properties window.
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|
|
Thanks for your answer.
Unfortunately I don't use any dataset designer.
I use the dataset object only for data visualsation in datagrid.
... <br />
myDataset = new DataSet();<br />
myAdapter.Fill(myDataset); <br />
this.myDatagrid.DataSource = myDataset.Tables[0]; <br />
I've been looking for NullValue property for dataset, but I couldn't find it:
myDataset.NullValue
myDataset.Tables[0].NullValue
myDataset.Tables[0].Columns[0].NullValue
No NullValue property for the objects above exists.
But I've found smtg like this:
<br />
this.myDatagrid.TableStyles[0].GridColumnStyles[0].NullText = "-";<br />
but this kind of error appears:
------------------------------------------------------------------------------
System.ArgumentOutOfRangeException: index was out of range. Must be non-negative or less than the size of the colletion.
Parameter name: index
at System.Collection.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.GridCollumnStylesCollection.get_Item(Int32 index)
at................................
-------------------------------------------------------------------------------
The this.myDatagrid.TableStyles[0] causes the error.
Has anybody got any idea what's wrong?
misiek
|
|
|
|
|
Hi,
There's an option I think in the data grid, or in the drata grid style where you can change the "null" value for the string that you want, sorry now I don't have the code with me, but search for something like "NullText".
HTH
Braulio
|
|
|
|