|
No sweat. Thanks for entertaining the question. Eventhough I do not have a solution yet, I fell better that at least one other person has come to the same conclusion. Looks like I need to write a home grown n-level menu.
Thanks again,
Don
|
|
|
|
|
Hello,
I'm trying to retrieve a page from a webserver, but I keep getting a "The server committed a protocol violation. Section=ResponseStatusLine" error in my program. This is using a the very simple code below:
<br />
string hostURL = "http://patft.uspto.gov";<br />
string URLSuffix = "/netacgi/nph-Parsernetacgi/" + "nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1" + "&u=/netahtml/srchnum.htm&r=1&f=G&l=50&" + "s1=6223224.WKU.&OS=PN/6223224&RS=PN/6223224";<br />
<br />
string lcUrl = hostURL + URLSuffix;<br />
HttpWebRequest webrequest =<br />
(HttpWebRequest)WebRequest.Create(lcUrl);<br />
webrequest.Timeout = 10000;
webrequest.UserAgent = "Code Sample Web Client";<br />
webrequest.ContentType = "text/html";<br />
webrequest.AllowAutoRedirect = true;<br />
<br />
HttpWebResponse loWebResponse = HttpWebResponse)webrequest.GetResponse();<br />
Encoding enc = Encoding.GetEncoding(1252);
StreamReader loResponseStream =<br />
new StreamReader(loWebResponse.GetResponseStream(), enc);<br />
string lcHtml = loResponseStream.ReadToEnd();<br />
<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
The problem appears, via HTTP trace, that the server is returning a code "200 Script results follow". I also downloaded the HTTP sniffer from The Code Project (HTTPeep) which did not function (threw off same error). Linux wget chokes as well.
Is there any way to force the program to treat that server code as a "200 OK" code, or to otherwise ignore it?
Thanks in advance,
Colin
|
|
|
|
|
I'm writing a progarm (mentioned in a previous posting) that populate a data grid, via a dataView whose "table" property is a DataTable. I've noticed that whenever I rerun the program, the listing on the dataGrid changes. The records are not loaded in the same order at all. The table is not changed at all, and the DataView.Sort property is set against 3 columns DataView.Sort = "ColName1, ColName2, ColName3";
any suggestions on how I can keep the row index of the DataTable from changing at every app restart?
Thanks
|
|
|
|
|
hi,
Can't you get row Index using this?:
this.dataGrid1.CurrentRowIndex.ToString()
dataGrid1 is a instance of DataGrid,
Regards,
pubudu.
|
|
|
|
|
I can, but since I'm selecting several rows at a time, the currentRowIndex doesn't help me.
|
|
|
|
|
hi,
You can get row index,If you select several rows:-
int a=dataGrid1.VisibleRowCount;
for(int i=0;i<a;i++)
{
if(datagrid1.isselected(i))
messagebox.show("row is="" "+i);
}
<="" b="">
regards,
pubudu.
|
|
|
|
|
Is it possible to use a custom control I made without including the dll along with the executable?
Thanks in advance.
|
|
|
|
|
Plainly not. You can't write code and have it execute on a machine you don't deploy it to.
You can write a custom control in the same project as your executable, then there is no dll.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah but then I cant use the form designer in Visual Studio...
Thanks for clearing this up for me though.
|
|
|
|
|
I am trying to send some message to an embeded device.
its a very simple protocol ,
for example., according to the documentation , When a client send a packet"0x0000", the device reboot, when send "0x0011 0x0001", the device start to
to rotate a certain degree.
I am a newbie to network programming, need a quick example on how to send a packet to a tcp/ip listener.
Thanks a lot!
|
|
|
|
|
Well, it may be self serving, but TransPort is the simplest way.
http://www.componentscience.net/elements/transport
Phillip H. Blanton
www.ComponentScience.net
Email: Phillip at that domain that you see one line above the line you are reading now.
|
|
|
|
|
Hi
I am working for a business company and build software for it as a developer(Web/Win).
But we have familirized ARIS and Rationalrose is told it builds any solution the Enterprise needs in a fast and lower cost using UML and Business Process Models.
My question is :
I will be fired ?
Their Solutions are as Complete as company would not need to me?
|
|
|
|
|
With software services like that, companies are tied to paying expensive consultants to write software how *they* think it should work, then pay the same consultants for maintenance, upgrades, and repairs.
Will you be fired? Haha somehow your whole post seems screwy with almost rhetorical questions written in poor English.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
|
I insert an OLe Object into my access DataBase and i found it saves as Pakager i don't understand what Pakager means and i can't retrieve the image from database to use it in my C# codes
plz i need help to write the query stmt for that
thanks
misho
|
|
|
|
|
|
Hi all,
I am trying to connect to an ACCESS database and read data from it. I believe the connection opens and closes fine, but when I add the line to Read from the data (ExecuteReader) I get the following exception error:
[An unhandled exception of type 'Microsoft.Data.Odbc.OdbcException' occurred in microsoft.data.odbc.dll]
////////////here is the code:
string connection= "Driver={Microsoft Access Driver (*.mdb)};"
+ "Dbq=I:\\ACCESS2000\\US_MASPS.mdb;" ;
OdbcConnection myConnection = new OdbcConnection(connection);
myConnection2.Open();
string select = "SELECT * from US_MASPS.TBLGMS"
+" WHERE SeqNo = 12";
OdbcCommand aCommand = new OdbcCommand(select, myConnection);
OdbcDataReader aReader = aCommand.ExecuteReader();
/////////////
I also downloaded and installed the latest MDAC and the ODBC driver (unless there is other stuff to be installed I am not aware of!)
Thanks in advance
|
|
|
|
|
hi,
first please put all the code part in the try and catch block.
then you easy to find the correct Error.
You are telling "when I add the line to Read from the data (ExecuteReader) I get the following exception error:
"
Then definitely it is not connection error ..It is a Error in the query you try to execute.
please check wheter the Table name and every thing is coeect in the Query.
regards,
pubudu
|
|
|
|
|
I have to make for school a project in C# that does the work of router.
I mean that i have to check on certain ports for an incomming connections and then check if there is a rule made for this port. If there is rule made for this then i have to forward this connection to a certain ip address or block it.
My user interface is done and i even created a service which will do the handling of the connections.
But i am stuck now with how will i forward a connection.
This is some of the function i made:
This is the function to create the socket:
{
LocalSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
LocalSocket.Blocking = false;
LocalSocket.Bind(new IPEndPoint(IPAddress.Parse(GetLocalIP()),
LocalRole.GetSourcePort()));
}
after that i call this function:
public void Start()
{
IAsyncResult ar = LocalSocket.BeginReceive(receive_buf_bytes, 0, len_receive_buf, SocketFlags.None, new AsyncCallback(CallReceive), this);
}
and this is the function that should forward the connection but i am not sure how to complete it:
private void CallReceive(IAsyncResult ar)
{
int received_bytes;
received_bytes = LocalSocket.EndReceive(ar);
//Receive(receive_buf_bytes, received_bytes);
if(LocalRole.GetSourceIp() != "0.0.0.0")
{
if(LocalRole.GetSourceIp() == ((IPEndPoint)(LocalSocket.RemoteEndPoint)).Address.ToString())
{
}
Start();
}
Could someone explain me how i should make this function to forward the connection?
thx
cyrus
|
|
|
|
|
Here is a generic Proxy class that forwards connections
class Proxy
{
private string appName = "HSMSProxy";
[STAThread]
static void Main(string[] args)
{
new Proxy().Start();
}
public void Start()
{
TcpListener listener = new TcpListener(5001);
listener.Start();
TcpClient activeEntity = listener.AcceptTcpClient();
TcpClient passiveEntity = new TcpClient("TargetMachine", 5002);
NetworkStream activeStream = activeEntity.GetStream();
NetworkStream passiveStream = passiveEntity.GetStream();
new InterStreamWriter(activeStream, passiveStream).Start();
new InterStreamWriter(passiveStream, activeStream).Start();
Console.ReadLine();
}
private void Log(string message)
{
Console.WriteLine(message);
}
}
class InterStreamWriter
{
NetworkStream readStream;
NetworkStream writeStream;
public InterStreamWriter(NetworkStream readStream, NetworkStream writeStream)
{
this.readStream = readStream;
this.writeStream = writeStream;
}
public void Start()
{
new System.Threading.Thread(new System.Threading.ThreadStart(ThreadFunc)).Start();
}
private void ThreadFunc()
{
while (true)
{
ArrayList byteList = new ArrayList();
byte[] myReadBuffer = new byte[1024];
int numberOfBytesRead = 0;
do
{
numberOfBytesRead = readStream.Read(myReadBuffer, 0, myReadBuffer.Length);
for (int i = 0; i<numberOfBytesRead; ++i)
byteList.Add(myReadBuffer[i]);
}
while(readStream.DataAvailable);
byte[] totalBuffer = (byte[])byteList.ToArray(typeof(byte));
writeStream.Write(totalBuffer, 0, totalBuffer.Length);
writeStream.Flush();
byteList.Clear();
}
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
will it work when a udp packet arrives ?
and can it work when set more than of ths objects and will it wait until a connection is made ?
|
|
|
|
|
You can make it work for UDP packets too. I'm not sure what you meant by your second question. It'll wait till a connection is made and will then connect to the target Machine:IP. After that, it is two way communication, either machine can send and receive data.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Sorry to bother again your code are already a great help.
But could you tell me how to make it work for udp .
Because im not sure how to do since there is no udplistener class .
thx for the help
Cyrus
|
|
|
|
|
I'm having a hard time handling logical palette's in C#. What I'm trying to do, is extract a palette from a 256 color bitmap, place it into a logical palette, select the logical palette as the current system palette, realize the new palette, and then draw the 256 color bitmap to the screen using the colors in it's palette (which is now the current system palette). Everything seems to be working great up to the point where I start drawing the bitmap. When I'm running the desktop in 256 color mode, it will only draw the bitmap in 16 colors (Windows standard colors) even though the palette is selected and realized correctly. I've included the code I've used to implement this. If anyone knows how to get this to work correctly, let me know. Thanks in advance! Anyway, here is the code I'm using.
<br />
IntPtr hWindowDC = IntPtr.Zero;<br />
<br />
public class User<br />
{<br />
[DllImport("user32.dll")]<br />
public static extern IntPtr GetDC(IntPtr hWnd);<br />
<br />
[DllImport("user32.dll")]<br />
public static extern void ReleaseDC(IntPtr hWnd, IntPtr hDC);<br />
}<br />
<br />
public class Gdi<br />
{<br />
[DllImport("gdi32.dll")]<br />
public static extern IntPtr SelectPalette(IntPtr hDC, IntPtr hPalette, bool bForceBackground);<br />
<br />
[DllImport("gdi32.dll")]<br />
public static extern int RealizePalette(IntPtr hDC);<br />
<br />
[DllImport("gdi32.dll")]<br />
public static extern int GetDeviceCaps(IntPtr hDC, int nIndex);<br />
<br />
[DllImport("gdi32.dll")]<br />
public static extern IntPtr CreatePalette([In] IntPtr lpLogPalette);<br />
<br />
public const int PC_RESERVED = 0x01;
public const int PC_EXPLICIT = 0x02;
public const int PC_NOCOLLAPSE = 0x04;
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct LOGPALETTE<br />
{<br />
public ushort palVersion;<br />
public ushort palNumEntries;<br />
public PALETTEENTRY palPalEntry;<br />
<br />
public LOGPALETTE(ushort entries)<br />
{<br />
this.palVersion = 0x300;<br />
this.palNumEntries = entries;<br />
this.palPalEntry = new PALETTEENTRY(0,0,0,0);<br />
}<br />
<br />
public int Length<br />
{<br />
get<br />
{<br />
return Marshal.SizeOf(palVersion) + Marshal.SizeOf(palNumEntries) + (this.palNumEntries * 4);<br />
}<br />
}<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct PALETTEENTRY<br />
{<br />
public byte peRed;<br />
public byte peGreen;<br />
public byte peBlue;<br />
public byte peFlags;<br />
<br />
public PALETTEENTRY(byte red, byte green, byte blue, byte flags)<br />
{<br />
this.peRed = red;<br />
this.peGreen = green;<br />
this.peBlue = blue;<br />
this.peFlags = flags;<br />
}<br />
<br />
public override string ToString()<br />
{<br />
return string.Format("{0} {1} {2}", Convert.ToString(peRed, 10), Convert.ToString(peGreen, 10), Convert.ToString(peBlue, 10));<br />
}<br />
<br />
}<br />
<br />
<br />
private static void LoadImagePalette()<br />
{<br />
Assembly exeAssembly = Assembly.GetExecutingAssembly();<br />
<br />
Stream imgStream = null;<br />
<br />
imgStream = exeAssembly.GetManifestResourceStream("MyPalette.image256.bmp");<br />
if( !(null==imgStream) )<br />
{<br />
Image image = Bitmap.FromStream( imgStream );
LOGPALETTE logPal = new LOGPALETTE((ushort)(image.Palette.Entries.Length));<br />
<br />
byte []paletteBytes = new byte[image.Palette.Entries.Length*4];<br />
<br />
for (int i=0; i < image.Palette.Entries.Length; i++)<br />
{<br />
paletteBytes[(i*4)] = image.Palette.Entries[i].R;
paletteBytes[(i*4)+1] = image.Palette.Entries[i].G;
paletteBytes[(i*4)+2] = image.Palette.Entries[i].B;
paletteBytes[(i*4)+3] = 0;
}<br />
<br />
IntPtr ptrPal = Marshal.AllocHGlobal(logPal.Length);<br />
Marshal.StructureToPtr(logPal, ptrPal, true);<br />
<br />
IntPtr palPalEntryAddress = new IntPtr(ptrPal.ToInt32() + Marshal.SizeOf(logPal.palVersion) + Marshal.SizeOf(logPal.palNumEntries) );<br />
Marshal.Copy(paletteBytes, 0, palPalEntryAddress, paletteBytes.Length);<br />
<br />
IntPtr hPalette = Gdi.CreatePalette(ptrPal);<br />
<br />
Gdi.SelectPalette(hWindowDC, hPalette, false);
Gdi.RealizePalette(hWindowDC);<br />
<br />
Graphics newGraphics = Graphics.FromHdc(hWindowDC);<br />
newGraphics.DrawImage(image, 0, 0);<br />
<br />
if (ptrPal != IntPtr.Zero)<br />
Marshal.FreeHGlobal(ptrPal);<br />
<br />
imgStream.Close();<br />
<br />
}<br />
}<br />
|
|
|
|
|
I'm creating an application in C# which is using the word automation. But i don't exactly understand how you can select the printer tray.
Also does anyone have a good tutorial on word automation on C# and printing
Master.Blaster
|
|
|
|
|