|
Having read the other posts and your replies, what you need to do is:
- open a transaction
- select the max u_id value plus one
- insert to both your tables
- commit the transaction.
This should ensure no duplication.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I'll admit I'm no SQL expert, but I don't think that opening a transaction will always ensure you don't get duplicate inserts in this case. All a transaction does is group the statements so you can ensure either all are executed (and a commit occurs) or none are executed (and a rollback occurs).
It is down to the isolation level settings[^] on the server to control what kind of locking takes place during a transaction.
The default (READ COMMITTED) allows other transactions to modify data in between statements in a transaction. Thus 2 transactions could both read the current max id (e.g. 5), both could then attempt an insert. The first would successful insert, the second would block. the first would then commit, which would allow the second to perform it's insert, which would cause a duplicate insert exception.
(I could be wrong about this, perhaps someone could explain if I have misunderstood the meaning of transaction isolation level)
Simon
|
|
|
|
|
Probably didn't explain it too well.
- begin tran
- update u_id table set u_id = u_id (does nothing except locks the table)
- select Max(u_id + 1)
- insert to both tables
- commit tran
While the u_id table is locked nobody else can update it.
So its not really the isolation level, it's my lack of explanation
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ahh, yes, I see what your talking about now.
Simon
|
|
|
|
|
A better explanation always helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Some people have got you on the right lines. The standard way to do this horrible hack, is to have a separate table that contains a row for the table you want to update. This row normally consists of a table name, and a sequence number.
In your code, you start a transaction, then you update the row to be row + 1. Next, select the same row - as you've updated it, you have the lock on the row. If somebody else tries to perform this operation, you have the row locked. Commit the transaction, and you have a new unique sequence.
|
|
|
|
|
hi
im desperately looking for a third party control or software that can print a windows form,eg my windows form has a picturebox with some labels
thanks very much
regards paula
|
|
|
|
|
There are several article here on cp that do what you want. A simple search should find them all.
|
|
|
|
|
PaulaM wrote: Print Window
Did you Google for 'PrintWindow' ?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
yes i have they are all using Bitmap to capture the window and i would have liked a control that u can modify the font etc
regards paula
|
|
|
|
|
No can do.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: Did you Google for 'PrintWindow' ?
I don't know about that but he has posted it on several forums.[^]
|
|
|
|
|
There are printers added on the remote machine.
I am using the following code to return the list of printers on this REMOTE machine.
Question:
Do you know why this code does NOT return the name of the printers?
Thanks
//list of remote printers...
string strWapiServer = "\\\\" + txtServerName.Text;
ConnectionOptions options = new ConnectionOptions();
options.Username = "username";
options.Password = "password";
options.Authority = "NTLMDOMAIN:omniad";
ManagementScope myScope = new ManagementScope(strWapiServer + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
//Iterate through printers...
foreach (ManagementObject oItem in oResults.Get())
{
string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
}
|
|
|
|
|
Hi Friends
namespace Test
{
[STAThread]
public static void Main()
{
Application.Run(MainForm)
}
public class MainForm : Form
{
public int MaxValue;
public A a = new A();
public MainForm()
{
MainValue = 100;
}
}
public class A
{
public B b = new B();
public A()
{
}
}
public class B
{
public B()
{
}
}
}
How to access variable MaxValue from MainForm to class B
thanks in advance
-kk.tvm-
|
|
|
|
|
It's very simple. Did I understand you?
You should create an object from your MainForm class in B class and then you can reach the variable MaxValue.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I suppose that you mean to set the MaxValue variable in the MainForm constructor, not the MainValue variable.
You can not access the value of the MaxValue variable from the B constructor, as it hasn't been assigned when the instance of the B class is created.
Besides that you create the B instance before the MainForm constructor runs, you need a reference to the MainForm instance to access it's members. You can send the reference to the constructor of the A class, so that it can send the reference along to the constructor of the B class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
you will have to use delegates!!! you´ll get used to it.
or download an articles about parent/child form method
if you are using more than 1 form, better forget it.
Use the above method or fill main_form with usercontrols to load pages(here you use delegate).It works fine for me.
see here an working exemple of delegates in action.
i trigger from usercontrol (with whatever event) a msg in form toolstrip_textbox
form
private void Form_Main_Load(object sender, EventArgs e)
{...
UserControl_RacePage_Child.Event_RacePageInfo += new UserControl_RacePage.Delegate_RacePageInfo(Page_Info);
...}
protected void Page_Info(string msg)
{ToolStripStatusLabel_MainInfo.Text = msg;}
usercontrol
public delegate void Delegate_RacePageInfo(string msg);
public event Delegate_RacePageInfo Event_RacePageInfo;
protected virtual void OnEvent_RacePageInfo(string msg)
{if (Event_RacePageInfo != null)
{ Event_RacePageInfo(msg); }}
protectec void button1_click(...)
{OnEvent_RacePageInfo("OK: Race added");}
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Here is my html file...
Problem..
i want to change $title$ while running a console application.
Can anyone help me?
Thnks in advance
Praji
|
|
|
|
|
Put your HTML-file into a string and change $TITLE$ with the help of the Replace()-method of the string-object.
Example:
<br />
string strHTML = "<html><head><title>$TITLE$</title></head><body></body></html>";<br />
strHTML = strHTML.Replace("$TITLE$", "www.codeproject.com");
|
|
|
|
|
Hi...
Plz... Help me...
I want some code for Converting a Number (money) to Words in Indian Format in C#.NET
eg.: if I enter 12345678 then it gives as ...
" ONE CRORE TWENTY THREE LAKHS FORTY FIVE THOUSAND SIX HUNDRED SEVENTY EIGHT "
if, anybody has this type of format Code .
regard&thanks
by
vidhya
|
|
|
|
|
We wont do your homework or interview questions. Try pay someone instead.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
cse.vidhya wrote: eg.: if I enter 12345678 then it gives as ...
" ONE CRORE TWENTY THREE LAKHS FORTY FIVE THOUSAND SIX HUNDRED SEVENTY EIGHT "
fetch the amount you mention here and any one will ready to do it ,
|
|
|
|
|
hello,
I am trying to send messages from my .NET Web application through the ozeki ng sms gateway and i'm really not finding any clear means of registering the remote object (ozSMSAPIHHTP) in my configuration file. Microsoft and ozeki don't seem to be of any help. can someone show me how?
thanks in advance!
//obinnaaj Eof
|
|
|
|
|
Good day all
I have got a string in c# as shown below, and i want to find and replace a substring within the string with another string.
here is the original string:
mystring = "Testing Image Embading \r\n \r\nEmage Embabeded here\r\n"
my string replace function:
mystring = mystring.Replace("src=\"/Web%20Cleint"/"Home%20Page"/"Images"/"Stop.png\","src=cid:companylogo");
My problem: is im have difficulties in handling escape characters, i keep getting the error "; missing" or newline in constant.
does anyone know i can solve this or help me with links on how to solve this.
Please note im working with web application.
|
|
|
|
|