Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
QuestionHow to split a string into 2 variables. Pin
Joshua1233218-Apr-08 16:13
Joshua1233218-Apr-08 16:13 
AnswerRe: How to split a string into 2 variables. Pin
PIEBALDconsult8-Apr-08 16:34
mvePIEBALDconsult8-Apr-08 16:34 
AnswerRe: How to split a string into 2 variables. Pin
Christian Graus8-Apr-08 17:01
protectorChristian Graus8-Apr-08 17:01 
GeneralValidating form field for HTML tags but Anchor text Pin
JohnyCoder8-Apr-08 16:02
JohnyCoder8-Apr-08 16:02 
GeneralAutomatically mapping printers... Pin
Jacob Dixon8-Apr-08 15:57
Jacob Dixon8-Apr-08 15:57 
GeneralTCP/IP Sockets Pin
#realJSOP8-Apr-08 11:25
mve#realJSOP8-Apr-08 11:25 
GeneralRe: TCP/IP Sockets Pin
Ravenet8-Apr-08 16:01
Ravenet8-Apr-08 16:01 
QuestionUpdating Child Table's Key (almost have it) Pin
MaxRelaxman8-Apr-08 10:58
MaxRelaxman8-Apr-08 10:58 
I'm trying to use a SqlDataAdapter to update a dataset containing multiple tables linked by a common parent table. I've set up my relations and ALMOST everything is working except for when my RowUpdated event handler tries to retrieve the identity field. Here's my code (without the try/catch/finally stuff and sanitized field names)

<br />
private void ParentRowUpdated(object sender, SqlRowUpdatedEventArgs e)<br />
{<br />
SqlCommand dbCommand = new SqlCommand("SELECT @@Identity");<br />
SqlConnection cn = new SqlConnection(GetConnString(m_strConnStringName));<br />
<br />
using (SqlConnection dbConn = new SqlConnection(GetConnString(m_strConnStringName)))<br />
{<br />
     using (SqlDataAdapter daAdapter = new SqlDataAdapter())<br />
     {<br />
        dbCommand.Connection = e.Command.Connection;<br />
        daAdapter.SelectCommand = dbCommand;<br />
        e.Row["p_key"] = Int32.Parse(daAdapter.SelectCommand.ExecuteScalar().ToString());<br />
        e.Row.AcceptChanges();<br />
}<br />
}<br />
}


Using @@Identity in my select query does retrieve the correct Identity value. However, when I try using SCOPE_IDENTITY() I get a blank value returned. I don't like using @@Identity because this will be a multi user system so I'm worried about getting the wrong value. Does anyone have any idea of a better way to do this?

Thanks!
GeneralSimple C # Solution Help Pin
Hulicat8-Apr-08 9:39
Hulicat8-Apr-08 9:39 
GeneralRe: Simple C # Solution Help Pin
pmarfleet8-Apr-08 11:15
pmarfleet8-Apr-08 11:15 
GeneralRe: Simple C # Solution Help Pin
Hulicat8-Apr-08 11:42
Hulicat8-Apr-08 11:42 
GeneralRe: Simple C # Solution Help Pin
Ravenet8-Apr-08 16:02
Ravenet8-Apr-08 16:02 
GeneralCalling a ASP.NET C# function from javascript Pin
Matt Cavanagh8-Apr-08 9:27
Matt Cavanagh8-Apr-08 9:27 
GeneralRe: Calling a ASP.NET C# function from javascript Pin
Pete O'Hanlon8-Apr-08 9:49
mvePete O'Hanlon8-Apr-08 9:49 
GeneralRe: Calling a ASP.NET C# function from javascript Pin
nelo_8-Apr-08 14:20
nelo_8-Apr-08 14:20 
GeneralExport DataGrid from different dynamically created tabpages to multiple worksheets of an Excel spreasheet Pin
Walaza8-Apr-08 7:09
Walaza8-Apr-08 7:09 
Generalproblems rightformating [modified] Pin
stephan_0078-Apr-08 6:24
stephan_0078-Apr-08 6:24 
GeneralRe: problems rightformating Pin
Luc Pattyn8-Apr-08 6:42
sitebuilderLuc Pattyn8-Apr-08 6:42 
GeneralRe: problems rightformating Pin
stephan_0078-Apr-08 10:03
stephan_0078-Apr-08 10:03 
GeneralChecking integer values and adding same types together Pin
Sharkadder8-Apr-08 6:23
Sharkadder8-Apr-08 6:23 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 7:25
carbon_golem8-Apr-08 7:25 
GeneralRe: Checking integer values and adding same types together Pin
Sharkadder8-Apr-08 7:50
Sharkadder8-Apr-08 7:50 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 16:37
carbon_golem8-Apr-08 16:37 
GeneralRe: Checking integer values and adding same types together Pin
Dave Kreskowiak8-Apr-08 7:55
mveDave Kreskowiak8-Apr-08 7:55 
GeneralRe: Checking integer values and adding same types together [modified] Pin
Sharkadder8-Apr-08 10:53
Sharkadder8-Apr-08 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.