回归价值观 [英] Returning values

查看:79
本文介绍了回归价值观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用ODBC命名空间和MySQl 4.1并且已经多次遇到这个问题并且不得不做一些讨厌的编码绕过

问题。我确信有一种更简单的方法可以做到这一点...


我在其中一张表中插入。我需要这个新密钥以某种方式返回

我的主叫代码。


我该怎么做?


以前我认为我已经做了类似选择陈述的事情

按插入日期订单然后从中读取密钥(返回

数据集)。

任何帮助都将不胜感激。


问候,


史蒂文

***已发送通过开发人员指南 http://www.developersdex.com ***

Hi,

I am using ODBC namespace and MySQl 4.1 and have hit this problem a
number of times and had to do some nasty coding to get round the
problem. I am convinced there is a easier way to do this...

I do an insert into one of my tables. I need this new key returned
somehow to my calling code.

How can I do this?

Previously I think I have done something like select statment which
orders by insert date then reading the key from that (returning a
DataSet).

Any help would be appreciated.

Regards,

Steven
*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

你指的是auto_increment的MySQL列吗?用于检索当前

连接上的最后一个自动增量值的MySQL SQL

语句是select last_insert_id()。只返回一行和一行

列,您可以通过ODBC发送该SQL语句并获得结果。


Alex

" Steven Blair" < ST ********** @ btinternet.com>在消息中写道

新闻:ep ************** @ TK2MSFTNGP15.phx.gbl ...
Are you referring to MySQL column that is auto_increment? The MySQL SQL
statement for retrieving the last auto increment value made on the current
connection is "select last_insert_id()" returns exactly one row and one
column, you can ODBC to send that SQL statement through and get the result.

Alex

"Steven Blair" <st**********@btinternet.com> wrote in message
news:ep**************@TK2MSFTNGP15.phx.gbl...

我正在使用ODBC命名空间和MySQl 4.1并且已经多次遇到这个问题并且不得不做一些讨厌的编码来解决问题。我确信有一种更简单的方法可以做到这一点...

我在其中一张表中插入。我需要将这个新密钥以某种方式返回给我的调用代码。

我该怎么办呢?

以前我觉得我做过像select statment这样的事情
按插入日期排序,然后从中读取密钥(返回一个
数据集)。

任何帮助将不胜感激。

问候,

Steven

***通过开发人员指南 http://发送www.developersdex.com ***



Yes auto inc。


问题是,我正在写一个网络应用程序,所以不使用

一直打开:|


任何otrher想法?

问候,


史蒂文


***通过Developersdex发送 http://www.developersdex.com ***
Yes auto inc.

The problem is, I am writing a web app so not using a conenction thats
open all the time :|

Any otrher ideas?

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***


好吧,如果你在做您的连接插入那个时候打开

所以在那个时候插入select last_insert_id以获得该字段的值

,如果你需要使用它那么从那里稍后例如你

可以将它添加到会话中。


Alex


" Steven Blair" < ST ********** @ btinternet.com>在消息中写道

news:eW ************** @ TK2MSFTNGP14.phx.gbl ...
Well if you are doing an insert your connection has to be open at that time
so plug in the select last_insert_id right at that point to get the value of
the field back, then from there if you need to use it later for example you
could add it to the session.

Alex

"Steven Blair" <st**********@btinternet.com> wrote in message
news:eW**************@TK2MSFTNGP14.phx.gbl...
Yes auto inc。<问题是,我正在编写一个网络应用程序,所以不要使用随时打开的连接:

任何otrher想法?
<问候,

Steven

***通过Developersdex发送 http://www.developersdex.com ***
Yes auto inc.

The problem is, I am writing a web app so not using a conenction thats
open all the time :|

Any otrher ideas?

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***



这篇关于回归价值观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆