|
Smells like SQL injection
|
|
|
|
|
|
PIEBALDconsult wrote: Linq?
Huh?
|
|
|
|
|
(Linq generates SQL, yes?)
|
|
|
|
|
Still not following how you get to LINQ
|
|
|
|
|
Hi all, thx for your reply.
The system use DataAdapter.Update() to update dataset
When user click SAVE button, it would run the following function.
AppFacade.SaveApp(dbConnectionString, dsAppData);
And SaveApp function as follows:
public void SaveApp(String dbConnectionString, DataSet dsData)
{
DBExecute dbexe = new DBEngine.DBExecute();
DataTable dtApp = dsData.Tables[AppData.SYS_TABLE_NAME];
DataTable dtLoc = dsData.Tables[AppDetailData.SYS_PROJ_LOCATION_TABLE];
......
......
try
{
dbexe.dbConnectionString = dbConnectionString;
dbexe.TransactionInitial();
dbexe.UpdateDataTable(dtApp);
dbexe.UpdateDataTable(dtExtApp);
......
......
dbexe.TransactionComplete();
}
catch (Exception e)
{
dbexe.TransactionRollBack();
throw e;
}
finally
{
dbexe = null;
dtApp = null;
dtExtApp = null;
......
......
}
}
// Public functions to update a datatable
public int UpdateDataTable(DataTable dt)
{
this.BuildCommands(dt.TableName);
if (dt.GetChanges() != null)
{
int intRtn = pAdapter.Update(dt.GetChanges());
return intRtn;
}
else
return 0;
}
public int UpdateDataTable(DataSet ds, string tableName)
{
this.BuildCommands(tableName);
if (ds.Tables[tableName].GetChanges() != null)
return pAdapter.Update(ds.GetChanges(), tableName);
else
return 0;
}
....
....
/// Public functions to build SQL command and parameters
private void BuildCommands(string tableName)
{
string strCommand = "SELECT * FROM " + tableName;
OleDbCommand comm = new OleDbCommand(strCommand, pConnection);
comm.CommandType = CommandType.Text;
comm.Transaction = myTrans;
pAdapter.SelectCommand = comm;
OleDbCommandBuilder cb = new OleDbCommandBuilder(pAdapter);
pAdapter.InsertCommand = cb.GetInsertCommand();
pAdapter.UpdateCommand = cb.GetUpdateCommand();
pAdapter.DeleteCommand = cb.GetDeleteCommand();
pAdapter.SelectCommand.Transaction = myTrans;
pAdapter.InsertCommand.Transaction = myTrans;
pAdapter.UpdateCommand.Transaction = myTrans;
pAdapter.DeleteCommand.Transaction = myTrans;
}
|
|
|
|
|
DataAdapter.Update can only work on very simple things; I suggest you avoid it.
|
|
|
|
|
HI
I want Output in gridview as
Site1 Site2 Siten Total
Pt1 5 0 10 15
Pt2 2 1 3 6
Pt3 1 2 1 4
Pt4 2 1 0 3
In above gridview Site1,site2,site3 and Pt1,pt2,Pt3,Pt4 these all shoul come dynamcally and count should also come dynamcally count like-5,10,15.
Please let me no code for this in C#
thnx
GroCareer
Waiting for replay
|
|
|
|
|
GroCareer wrote: In above gridview Site1,site2,site3 and Pt1,pt2,Pt3,Pt4 these all shoul come dynamcally and count should also come dynamcally count like-5,10,15.
Come from where?
GroCareer wrote: Please let me no code for this in C#
Why? try for yourself and post your code if it doesn't work, then someone will help.
Next you'll be saying its urgent - probably because youi need to habd your homework in.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hello everyone,
I am migrating from C++ to C#. And I am debugging a multi-threaded program and I need to print out the thread ID. In C++, I am using GetCurrentThreadID method, but in C#, I only find Thread.CurrentThread.ManagedThreadId.
My questions are,
1.
Does Thread.CurrentThread.ManagedThreadId have the same effect and can serve my purpose?
2.
I am confused about what means "ManagedThreadId", does there is some peer called "NonManagedThreadId"?
thanks in advance,
George
|
|
|
|
|
Hi George,
1. no
2. no
there is no link between managed threads and kernel threads.
managed threads are logical things, kernel threads are physical things.
even if it seems there is a one-to-one correspondence, .NET does not promise that;
in fact they claim multiple managed threads could be executed by a smaller number of
kernel thread.
As a consequence, there is simply NO WAY to identify your threads; not by name (Windows
does not know about thread names), and not easily by thread IDs, they are confusing
at the least.
What you can do is catch the managed thread ID when the thread gets created,
attach a thread name to it (using a Hashtable/Dictionary), then keep track of your
threads by asking them their ID, and look up the thread name you assigned earlier.
But that is a rather clumsy workaround for a lernel shortcoming.
|
|
|
|
|
Thanks Luc,
1.
My application is pure C# application, and I want to dump thread ID to detect the behavior of each thread, so that I can find deadlock/re-entrance/how many times a thread enters a specific method, something like this.
After reading document, I am confused whether I can use ManagedThreadId property, my concern is for example, whether two threads will map to the same ManagedThreadId, so that the monitor is not accurate to serve my purpose.
2.
Luc Pattyn wrote: As a consequence, there is simply NO WAY to identify your threads; not by name (Windows
does not know about thread names), and not easily by thread IDs, they are confusing
at the least.
Why not can not be identified by ManagedThreadId? Could you show me a scenario please?
3.
Luc Pattyn wrote: What you can do is catch the managed thread ID when the thread gets created,
attach a thread name to it (using a Hashtable/Dictionary), then keep track of your
threads by asking them their ID, and look up the thread name you assigned earlier.
But that is a rather clumsy workaround for a lernel shortcoming.
I am confused why ManagedThreadId is not enough? Could you show me a scneario when just using ManagedThreadId is not enough please?
regards,
George
|
|
|
|
|
|
|
ryrt ruyeuttruuer e re njsdrfg irire ergtri tegr regtrre reirtirtgiers rtretrtgre
|
|
|
|
|
Can you speak English please?
regards,
George
|
|
|
|
|
Hi George,
ManagedThreadId is fine for identifying threads within .NET with two remarks:
1. it is a number, not a name; important stuff should be identified by name.
2. it does not map easily to the thread IDs as can be seen from other tools, such as
Task Manager, SystemInfo, etc.
|
|
|
|
|
Thanks Luc,
1.
Luc Pattyn wrote: 2. it does not map easily to the thread IDs as can be seen from other tools, such as
Task Manager, SystemInfo, etc.
Because Task Manager will use a different ID? And ManagedThreadId is just CLR internal thread ID?
2.
What do you mean this before?
--------------------
As a consequence, there is simply NO WAY to identify your threads; not by name (Windows
does not know about thread names), and not easily by thread IDs, they are confusing
at the least.
--------------------
Why no way? I think you mentioned in last post ManagedThreadId is ok to identify -- "ManagedThreadId is fine for identifying threads within .NET"?
regards,
George
|
|
|
|
|
Hi George,
I found no easy way to relate ManagedThreadID inside a .NET app to the Thread IDs listed
by kernel-level tools such as Task Manager, SystemInfo, etc. That makes it hard to
observe multi-threading behavior unless you build a lot of code into the app itself.
|
|
|
|
|
Thanks Luc,
--------------------
As a consequence, there is simply NO WAY to identify your threads; not by name (Windows
does not know about thread names), and not easily by thread IDs, they are confusing
at the least.
What you can do is catch the managed thread ID when the thread gets created,
attach a thread name to it (using a Hashtable/Dictionary), then keep track of your
threads by asking them their ID, and look up the thread name you assigned earlier.
But that is a rather clumsy workaround for a lernel shortcoming.
--------------------
So, you think the same is the same in TaskManager and in the .Net App -- even if the ID are not the same? And you use name to link the relationship between them?
regards,
George
|
|
|
|
|
Hi George,
no
1. I have no way to link managedThreadID (inside app) to kernel thread ID (tools outside app).
2. I use names to log threads, not IDs, to get a human readable log.
|
|
|
|
|
Thanks Luc!
Anyway, using ManagedThreadId is enough for my requirement, right?
(I quote my requirement again here)
--------------------
My application is pure C# application, and I want to dump thread ID to detect the behavior of each thread, so that I can find deadlock/re-entrance/how many times a thread enters a specific method, something like this.
After reading document, I am confused whether I can use ManagedThreadId property, my concern is for example, whether two threads will map to the same ManagedThreadId, so that the monitor is not accurate to serve my purpose.
--------------------
regards,
George
|
|
|
|
|
Hi George
yes
and different Threads will have different ManagedThreadId.
|
|
|
|
|
Thanks Luc,
Question answered. Always happy to learn from you.
regards,
George
|
|
|
|
|
You're welcome.
|
|
|
|
|