|
Getting the largest id is not a safe way to get the id of the record. If another user added a record at the same time, you will get the wrong id. Consider this scenario:
:: User 1 adds a record, which gets id 42.
:: User 2 adds a record, which gets id 43.
:: User 1 gets the highest id, which is 43.
:: User 2 gets the highest id, which is 43.
Now both users think that they added the record with id 43.
Using @@identity on the other hand is completely safe. A user will always get the last id that was created in the database session, e.g. with the same database connection.
---
b { font-weight: normal; }
|
|
|
|
|
you know.. the best way to undersatand this is to try it;)
i will try to check it on a small application
thanks
Tamimi - Code
|
|
|
|
|
Guffa wrote: Using @@identity on the other hand is completely safe
In SQL Server, you never used to be assured to 100% always get the right id with @@identity. So in sql server 2000 they added a built in fuction called SCOPE_IDENTITY() which is AFAIK 100% guaranteed to get you the right ID.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Correct. I mentioned the scope_identity function in the previous thread:
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mode=all&userid=3050175&select=1532206&df=100&tid=1531522#xx1532206xx
AFAIK there is only a difference between @@identity and scope_identity() when you are using triggers that uses inserts.
@@identity will always return the last id created in the session, but if the trigger also inserts a record you will get the id of that record instead of the id from the insert that caused the trigger to run.
---
b { font-weight: normal; }
|
|
|
|
|
I created a screensaver project, used all the default settings. When the project is completed, it works fine with two images (SSaverBrackground,SSaverBrackground2). I cannot find A way to add more images.
Any help is greatly appreciated
Using VS 2005
|
|
|
|
|
i have a dataset that is filled from a webservice. The dataset will contain a table with 2 columns. What's the code to bind the DysplayMember property to one of the Columns and the Value member to the other one??
rzvme
|
|
|
|
|
u can use
comboBox1.DataSource=Dset.Tables["table name"];
comboBox1.DisplayMember="column1 name";
comboBox1.ValueMember="column2 name";
rahul
|
|
|
|
|
tried that too: error:An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Could not bind to the new display member.
rzvme
|
|
|
|
|
try to check that u have used same column names which are used in table in database.
rahul
|
|
|
|
|
defenently the same name...let's say i used the northwind database..and the categories table
this is the code:
private void Form1_Load(object sender, System.EventArgs e)
{
myserv.Service serv = new myserv.Service();
dataSet1=serv.GetNames();
dataSet2=serv.GetNames();
comboBox1.DataSource=dataSet1;
comboBox1.ValueMember="CategoryID";
comboBox1.DisplayMember="CategoryName";
}
i just can't avoid this error
rzvme
|
|
|
|
|
How do I connect to MySQL using C#?
What do I need to do so?
plz help me out ...!!!
I have never used MySQL before, all help is greatly appriciated.
phil chris
|
|
|
|
|
create DSN of ur database
System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("DSN='dsn name'");
conn.Open();
rahul
|
|
|
|
|
They are also a MySqlconnector , search it on the mysql site
bye
|
|
|
|
|
Thanks for the help so far guys.
KnOw yAr Rol3,
phil chris
|
|
|
|
|
hello,
does anybody know how to determine the pixel width of a string if given the font and font size? i would like to be able to do this using c#, but i have no idea where to start.
thanks!!!
RC
|
|
|
|
|
You can probably look here -> [TextRenderer.MeasureText]
It's new to the .NET 2.0 framework according to MSDN website. There are examples in VB and C# about 3/4 of the way down the page.
Hope this gets you off in the right direction.
Mike Poz
|
|
|
|
|
Hello all,
I have just got this new HP Compaq nx6125 laptop which has a finger scanner which helps me to log into the computer. I was just thinking does anyone know how we can program the finger scanner to reconize the finger. In short how to i learn finger scanning programming...
I know its very hard... but if any one has any code or any directly i would really appreciate it a lot..
CH
|
|
|
|
|
I'm not sure where to begin, but I would say that C# probably isn't the right tool for the job. You're most likely going to have to work with device drivers in C, that'd be my suggestion of where to start looking, at least.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
hi! CP people!!
it's my first time to post a question here, but i tend to consult CP whenever i have programming problems.
my problem here is that i have two textboxes. one is read-only and the other one is not.
now, what i want to do here is to show what the user typed in the textbox which doesnt have the read-only property to the other textbox which is read-only.
i really don't know how to start the coding because it's only been a year since i'm learning C# .NET and my professor in C# doesnt help at all. i can assure you that is not a school project. i just want to learn from you guys rather than to consult my professor.
thanks in advance...
|
|
|
|
|
Hiya,
TextBox textBox1=new TextBox();
textBox1.KeyPress+=new KeyEventHandler(UpdateTextBox);
...
TextBox textBox2=new TextBox();
textBox2.ReadOnly=true;
...
private void UpdateTextBox(object sender,KeyEventArgs e)
{
textBox2.Text=textBox1.Text;
}
Even if textboxes are read-only to the user, .net still can write to it in code.
Hope this will do!
Graham
|
|
|
|
|
it helps logic wise. i tweak the codes a bit but thanks anyways.
Regards...;)
in land of the idiots, the imbecile is the king.
|
|
|
|
|
well u can do like this
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
textBox2.Text=textBox1.Text;
textBox2.ReadOnly=true;
}
it will help u
Yogesh_T
|
|
|
|
|
Hi there!
Please help, I am trying to show the data from an SQL select statement into textboxes.
Here is what I have so far:
SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=CB;Integrated Security=SSPI;");
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM tblCB WHERE CBID='"+ this.CBID.Text +"'", conn);
cmd.ExecuteNonQuery();
conn.Close();
sasa
|
|
|
|
|
Replace:
spatwa wrote: cmd.ExecuteNonQuery();
with:
using (SqlDataReader reader=cmd.ExecuteReader()) {
if (reader.HasRows) {
reader.Read();
textBox.Text=reader.GetString(reader.GetOrdinal("ColumnName"));
}
reader.Close();
}
|
|
|
|
|
Thanks a million Graham, I appreciate your help.
sasa
|
|
|
|