|
you do message.Length
you mean fixString.Length here
Am i right
even than its crashing for my message
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
My Mistake
It should be fixArray
Here's your code
String fixString = "Whateever";<br />
string[] fixArray = fixString.Split(Convert.ToChar(1)); <br />
HashTable fixTable = new HashTable();<br />
string[] fieldArray = null;<br />
for (int fieldCount = 1; fieldCount < fixArray.Length; fieldCount++)<br />
{<br />
fieldArray = fixArray[fieldCount].Split('=');<br />
fixTable.Add(fieldArray[0].ToString(), fieldArray[1].ToString()); <br />
}<br />
string firstTagString = fixTable["100"].ToString()
|
|
|
|
|
its still giving index was outside the bounds of array
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Can you post your code here?
Also provide the string which you using
|
|
|
|
|
try
{
String fixString = newLine;
string[] fixArray = fixString.Split(Convert.ToChar(1));
//I used 1 because FIX message uses this as delimiter...
Hashtable fixTable = new Hashtable();
string[] fieldArray = null;
for (int fieldCount = 1; fieldCount < fixArray.Length; fieldCount++)
{
fieldArray = fixArray[fieldCount].Split('=');
fixTable.Add(fieldArray[0].ToString(), fieldArray[1].ToString());
}
string firstTagString = fixTable["100"].ToString();
}
catch(Exception ex)
{
String x=ex.ToString();
}
"M|2696|0|D|I|20070604-19:31:25.177|255|8=FIX.4.29=23235=D34=269649=Qa-QTIP-Sim-A56=Qa-QTIP-Sim-A-Internal52=20070604-23:31:2540=1MDSNAPID=6071=511=Q8BO7023-121=4955=QQQQ59=05011=12463/2007-06-04-07:3138=100109=RajTest5012=Raj9040=NSTRATEGY=PassThru54=147=A100=ARCA10=169|0|\r"
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Here it is:
try<br />
{<br />
string newLine = "M|2696|0|D|I|20070604-19:31:25.177|255|8=FIX.4.29=23235=D34=269649=Qa-QTIP-Sim-A56=Qa-QTIP-Sim-A-Internal52=20070604-23:31:2540=1MDSNAPID=6071=511=Q8BO7023-121=4955=QQQQ59=05011=12463/2007-06-04-07:3138=100109=RajTest5012=Raj9040=NSTRATEGY=PassThru54=147=A100=ARCA10=169|0|\r";<br />
String fixString = newLine;<br />
string[] fixArray = fixString.Split(Convert.ToChar(1));<br />
Hashtable fixTable = new Hashtable();<br />
string[] fieldArray = null;<br />
try<br />
{<br />
for (int fieldCount = 0; fieldCount < fixArray.Length; fieldCount++)<br />
{<br />
fieldArray = fixArray[fieldCount].Split('=');<br />
fixTable.Add(fieldArray[0].ToString(), fieldArray[1].ToString());<br />
}<br />
}<br />
catch<br />
{ <br />
<br />
}<br />
string firstTagString = fixTable["100"].ToString();<br />
MessageBox.Show(firstTagString);<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}
Let me know if this works...
|
|
|
|
|
after this line
string firstTagString = fixTable["100"].ToString();
it jumps out and go to lines after
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Dude,
I ran it with the same code...
If it is running for exception than it means ur message did not contain message with tag 100...
nyway, for which company do you work?
|
|
|
|
|
ya
it works fine
catched the exception then read the value
thanks a lot for help
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
I am new in Oracle and now I'm am struggling to insert into the Oracle Database. The DB connection is fine. I keep getting the error "ORA-01036:illegal variable name/number". Would anyone please tell me what is wrong with the following code (C#):
// Insert user into Tester Table
public void InsertIntoTester(string fname,string lname,string usrname,string passwd,string address, string email, string tester_id)
{
Connection.Open();
string strSQL;
string insertValue= "'"+fname+"',"+"'"+lname+"',"+"'"+usrname+"',"+"'"+passwd+"',"+"'"+address+"',"+"'"+email+"',"+"'"+tester_id+"'";
strSQL = " INSERT INTO TESTER (FIRSTNAME, LASTNAME, USRNAME, PASSWD, ADDRESS, EMAIL, TESTERID) VALUES ("+insertValue+")";
//Initializing the command
InsertCommand.CommandType = System.Data.CommandType.Text;
InsertCommand.CommandText = strSQL;
//Clearing the parameters
InsertCommand.Parameters.Clear();
InsertCommand.Parameters.Add(":FIRSTNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":LASTNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":USRNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":PASSWD",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":ADDRESS",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":EMAIL",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":TESTERID",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters[0].Value = fname;
InsertCommand.Parameters[1].Value = lname;
InsertCommand.Parameters[2].Value = usrname;
InsertCommand.Parameters[3].Value = passwd;
InsertCommand.Parameters[4].Value = address;
InsertCommand.Parameters[5].Value = email;
InsertCommand.Parameters[6].Value = tester_id;
insertValue = strSQL;
InsertCommand.ExecuteNonQuery();
Connection.Close();
}
Please help..
Mvelo Walaza
Jnr Developer
Telkom SA
|
|
|
|
|
You are injecting the values in to the SQL command and they you are passing the same data in as parameters. Please stick with the parameters and alter your SQL String so that you are actually using the parameters that you set up.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
I'm not sure I understand what you are saying. Would you please alter the code that I sent to you to reflect that what you are saying? thanx in advance for your response.
Mvelo Walaza
Jnr Developer
Telkom SA
|
|
|
|
|
Walaza wrote: string strSQL;
string insertValue= "'"+fname+"',"+"'"+lname+"',"+"'"+usrname+"',"+"'"+passwd+"',"+"'"+address+"',"+"'"+email+"',"+"'"+tester_id+"'";
strSQL = " INSERT INTO TESTER (FIRSTNAME, LASTNAME, USRNAME, PASSWD, ADDRESS, EMAIL, TESTERID) VALUES ("+insertValue+")";
This injects the values into the SQL. This is the source of a SQL Injection Attack, so you don't want to be injecting values.
Walaza wrote: InsertCommand.Parameters.Add(":FIRSTNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":LASTNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":USRNAME",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":PASSWD",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":ADDRESS",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":EMAIL",System.Data.OracleClient.OracleType.VarChar,255);
InsertCommand.Parameters.Add(":TESTERID",System.Data.OracleClient.OracleType.VarChar,255);
What you want to do is alter the SQL String you've set up so that it doesn't inject values into the string.
So... Change insertValues to be a string that contains the parameter names rather than injecting the actual values. So it reads something like this:
string insertValue= ":FIRSTNAME, :LASTNAME, :USRNAME, :PASSWD, :ADDRESS, "+
":EMAIL, :TESTERID";
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
How do I pass objects to threads? VS2005 let me say, t.start((object)obj); but VS2003 (1.1) doesnt. Why? How do I do that in .net 1.1?
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
You can use the static variables for this.
|
|
|
|
|
And if you have multiple threads starting at once?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Didnt get you
How can you have threads starting at once?
|
|
|
|
|
In a multithreaded environment you can have mulitple things happening at the same time, especially in a multicore or multiprocessor environment.
So, how does your solution work if you want to start several threads at the same time?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
In .Net 1.1 the ThreadStart never takes a parameter, so you the method which is called on a new thread will have to access the object stored some where else. But keep in mind to make thread safe.
Though this is now possible in 2.0 using Annonymous Methods.
Hope, it is clear now
|
|
|
|
|
If threads need different parameters we can name each thread (or group of) and use static hash table (dictionary) to store the parameters.
P.S. I think it is good way to solve this. But I have never worked with FW 1.1. May be it has a different recommended solution
|
|
|
|
|
you could do this:
create a class that will execute on the thread.
public class ThreadObj
{
private int t1;
private string t2;
public int T1
{
get
{
return t1;
}
set
{
t1 = value;
}
}
public string T2
{
get
{
return t2;
}
set
{
t2 = value;
}
}
public void MyThreadMethod()
{
string t = t2;
}
}
then call this with :
ThreadObj o = new ThreadObj();
o.T2 = "Hello";
o.T1 = 1;
System.Threading.ThreadStart ts = new System.Threading.ThreadStart(o.MyThreadMethod);
System.Threading.Thread tr = new System.Threading.Thread(ts);
tr.Start();
|
|
|
|
|
Hello friends!
I was programming redirection of output from console process(C# .Net 2.0), but when i'm outputing it on form it outputs illegal characters(cyrillic characters).
Could you help me how to convert this cyrillic output from the console app to unicode?
Thanks.
-- modified at 6:15 Friday 8th June, 2007
|
|
|
|
|
hi,
did you try System.Text.UnicodeEncoding... or System.Text.Encoding.Unicode....
hope that helps
regards
|
|
|
|
|
Hello guys
in dot net 2.0 we have generic list in system.collection.generic ,
but not in dot net 1.1 , so how can we achieve that functionaly in dot net 1.1 , is there any way ?
thanks in advance
hello
|
|
|
|
|
I think not. Generics have been introduced to C# with version 2.0 of the language.
|
|
|
|
|