|
Your scanner should come with drivers which handle the reading. They often have an option to return the code as a number.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
using System;
using System.IO.Ports;
class MyClass
{
public static void Main()
{
SerialPort sp = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
sp.Open();
while (true)
{
try
{
string dataReceived = sp.ReadLine();
Console.WriteLine(dataReceived);
}
catch(TimeoutException)
{
}
}
}
}
|
|
|
|
|
when try open the portname show a massage (the port (PortName)Does not exist)
please resolve my problem
my scanner is usb
123
|
|
|
|
|
I'm having to write some relatively ugly code when their realy ought to be a better way to do this. I'm sure someone has come across this before.
We are receiving messages from/ sending messages to a legacy host system that MUST be aligned a specific way.
For example I have a structure like:
struct myexample
{
public fixed byte mybytes[15];
public int myint;
public int myint2;
}
I'm not showing it here, but i use the system.runtime.interopServices.FieldOffset to make sure the bytes line up exactly correct.
I go to fill in this structure with some data
public void fillItin(string myString,
int myInt,
int myOtherInt)
{
myexample temp = new myexample();
temp.myint = myInt;
temp.myint2 = myOtherInt;
byte[] myArray = ascii.GetBytes(myString);
// cool I've got it into a byte[] structure, but now I need to convert it to my fixed
//length byte which c# treats as a byte*
// this is what I've been doing, but there MUST be a better way!
// Yuck! Way too unelegant of a solution. Help!
unsafe
{
for (int i=0;i<myarray.length;i++)
="" {
="" if="" (i="" <="" 15)="" temp.mybytes[i]="myArray[i]
" }
="" }
="" now="" convert="" my="" structure="" to="" a="" byte[]="" array="" (cool="" marshal="" utilities="" work="" well="" here)
="" and="" send="" it="" off="" ...="" some="" code="" here="" the="" message=""
}=""
<div="" class="ForumSig">Kim Ferrari
|
|
|
|
|
I believe you are using "fixed" in the wrong place. You can copy the array as you would normally do in normal C# coding. Then you pin the struct when you use it with the legacy code. Here is an example taken from Microsoft's .Net Framework documention on the C# key word "fixed":
using System;
class Point
{
public int x, y;
}
class FixedTest
{
unsafe static void SquarePtrParam (int* p)
{
*p *= *p;
}
unsafe static void Main()
{
Point pt = new Point();
pt.x = 5;
pt.y = 6;
fixed (int* p = &pt.x)
{
SquarePtrParam (p);
}
Console.WriteLine ("{0} {1}", pt.x, pt.y);
}
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
How c# app connect to sql server on another pc in local network?
Is connection string same when server on local pc?
Is there diversity if server is sqlexpress?
Thanks for any help.
|
|
|
|
|
You need to put the PC name into the connection string in place of (local).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks. I use below conection string, but there's appear error in remote connection.
On same pc connection is OK.
mConnection = new SqlConnection(@"data source=servername\sqlexpress;" +
"database=databasename;" +
"UID=user;PWD=pass;");
Error mesage is:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Server Authentication is SQL Server and Windows Authentication mode.
Allow remote connections to this server is set.
What may cause this mistake?
|
|
|
|
|
By default, Sql Server 2005 blocks remote connections. This is an intentional security measure that you can override. Just set Sql Server to accept remote connections.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I realize this is technically a general .net question, but since this form gets many times more traffic than the .net Framework one, forgive me for thinking I have a better chance of getting an answer here. (Besides, I'll be implementing it in C# anyway)
Simple Question: Using a basic TabControl, is there any way I can get the tabs to render (and respond to clicks! That's an important bit...) centered?
More Complex Version: The centering thing above is just an example, and actually not what I want to do, but it would demonstrate the behavior that I want, which is to be able to offset the tabs from corner of the tab control by a certain pixel amount to make room for additional buttons (like a Mozilla-style drop-down). An even better question still may be, Do I have any control whatsoever over the rectangle that the tabs draw in, or the tab rectangles themselves? Please note that I would like to use the basic TabControl if at all possible.
Thank you!
--Toji
|
|
|
|
|
i wanna know how to use open file dialog control in C# aps.net web application.as i have to save the downloading attachment file on my system through my application. i want help in C# coding instead Asp.
Thanx
|
|
|
|
|
|
No actually i need its solution not for Windows application i need the sloution for Asp.net web application.
regards n thanx
|
|
|
|
|
For an ASP.NET app, you should look into using the following server control
<br />
<asp:FileUpload runat=server /><br />
Here is a link that tells more about using it...
|
|
|
|
|
There is a new FileUpload server control provided in ASP.NET 2.0 which allows you to browse to the file location.
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Hi All,
I want to know how can i replace a value in a XML (e.g)
<connectionstring>
<userid>test123
Here in this example i want to replace the value of "userid" form "test123" to some other value. I want to access the node directly. How can i acheive this in C#.
Will anyone help me..
Thanks in advance
Umashanker.k
|
|
|
|
|
One Post is enoough.
Regards,
Satips.
|
|
|
|
|
Hi satips,
I am pleased with u, if u had added the real answer to my question, anyways thx
|
|
|
|
|
Modify your post and check the "Ignore HTML tags in this message (good for code snippets)" checkbox at the bottom so we can all see the xml.
|
|
|
|
|
Hi All,
My question is how can i replace a value in XMl in C#, directly accesiing that node.
(e.g)
<?xml version="1.0"?>
<configurationsettings xmlns:dt="urn:schemas-microsoft-com:datatypes">
<connectionstring>
<userid>test123</userid>
</connectionstring>
</configurationsettings>
here i want to replace the value "test123" to some other value, how can i achieve this .will anyone help in this
thanks
Umashanker.K
|
|
|
|
|
Load the XML into a XmlDocument , use the SelectSingleNode to select the userid node and change its value via an appropriate property of the XmlNode instance returned by SelectSingleNode . Take a look at the documentation of the mentioned classes and method and the continuative links. Their are many examples and personally I think their use is straightforward.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi All,
I want to know how can i replace a value in a XML (e.g)
<configurationsettings xmlns:dt="urn:schemas-microsoft-com:datatypes">
<connectionstring>
<userid>test123
Here in this example i want to replace the value of "userid" form "test123" to some other value. I want to access the node directly. How can i acheive this in C#.
Will anyone help me..
Thanks in advance
Umashanker.k
|
|
|
|
|
Load it into an XmlDocument and use XPath to find/replace the value.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
OK, this is obscure.
I've got a remoting service that creates a form, and I've got remoting client that needs to hide and show the form. Calling Show or Hide occasionally never returns.
I've verified that that thread ID is the same that created the form and is now calling Show/Hide on the remote server. Though I'm wondering if that's a problem.
BTW, the Form was created with a factory method, so we're not dealing with Singleton or SingleCall lifetime issues, though we may be dealing with lifetime issues for other reasons. Hmmm.
Anyways...anyone have even a clue what might be the problem?
Thanks!
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
I'm not sure I understand: the .NET remoting server creates the form and sends that to the client?
In any case, my guess is either your service object lifetime is expired, you're talking to the form on the wrong thread, or the form was created on an MTA thread.
|
|
|
|