In normal asp i used
---------
objRS.Open "tbl_Nieuws", objConn, 1, 3
objRS.AddNew
objRS.Fields("N_Datum") = FormatDateTime(Now(),2)
objRS.Fields("N_Title") = ReplaceHTML(Upload.Form("title"))
objRS.Fields("N_Intro") = ReplaceHTML(Upload.Form("intro"))
objRS.Fields("N_Body") = ReplaceHTML(Upload.Form("body"))
objRS.Fields("N_UserID") = Upload.Form("id")
objRS.Fields("N_Image") = file.Filename
objRS.Fields("N_Ip") = strIP
objRS.Fields("N_Deleted") = 0
objRS.Update
IntID = objRS("N_ID")
objRS.Close
---------
to get the id of the record i just added.
in asp.net i have this but i dont know how i can accomplish the same and
wanted to know if there
is some easyway for it.
-----------------
Dim myConnection As New SqlConnection(AppSettings("DatabaseCon"))
Dim strSQL As String = "insert into tbl_Users" & _
"(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code,
U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned,
U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _
"values('"& tbGebruikersNaam.Text & "'," & _
"'"& tbWachtwoord.Text & "'," & _
"'"& tbEmailAdres.Text & "'," & _
""& strKlantenNR &"," & _
"'"& i & "'," & _
"1," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'no_avatar.gif'," & _
"'"& strIP & "'," & _
"0," & _
"0," & _
"'"& strMSN & "')"
Dim MyCommand As New SqlCommand(strSQL, myConnection)
myConnection.Open()
MyCommand.ExecuteNonQuery()
myConnection.Close()
--------------
i want the record of the record i just added to the tbl_Users. How 2? thats
the question.
thx in advance,
Richard 4 1727
please post this question in this newsgroup:
microsoft.public.dotnet.framework.adonet
( news://news.microsoft.com/microsoft....amework.adonet)
--
Hope this helps,
Zeeshan Mustafa, MCSD
"Richard" <ri*****@nospam.com> wrote in message
news:40**********************@newsreader.eweka.nl. .. In normal asp i used ---------
objRS.Open "tbl_Nieuws", objConn, 1, 3 objRS.AddNew
objRS.Fields("N_Datum") = FormatDateTime(Now(),2) objRS.Fields("N_Title") = ReplaceHTML(Upload.Form("title")) objRS.Fields("N_Intro") = ReplaceHTML(Upload.Form("intro")) objRS.Fields("N_Body") = ReplaceHTML(Upload.Form("body")) objRS.Fields("N_UserID") = Upload.Form("id") objRS.Fields("N_Image") = file.Filename objRS.Fields("N_Ip") = strIP objRS.Fields("N_Deleted") = 0
objRS.Update IntID = objRS("N_ID") objRS.Close
--------- to get the id of the record i just added. in asp.net i have this but i dont know how i can accomplish the same and wanted to know if there is some easyway for it.
-----------------
Dim myConnection As New SqlConnection(AppSettings("DatabaseCon")) Dim strSQL As String = "insert into tbl_Users" & _ "(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code, U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned, U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _ "values('"& tbGebruikersNaam.Text & "'," & _ "'"& tbWachtwoord.Text & "'," & _ "'"& tbEmailAdres.Text & "'," & _ ""& strKlantenNR &"," & _ "'"& i & "'," & _ "1," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _ "0," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _ "0," & _ "'no_avatar.gif'," & _ "'"& strIP & "'," & _ "0," & _ "0," & _ "'"& strMSN & "')"
Dim MyCommand As New SqlCommand(strSQL, myConnection) myConnection.Open() MyCommand.ExecuteNonQuery() myConnection.Close()
-------------- i want the record of the record i just added to the tbl_Users. How 2?
thats the question.
thx in advance,
Richard
eeuh? Okay althrou i dont know why i cant ask the question here? its asp.net
as far i know.. :S
Richard
"M. Zeeshan Mustafa" <ze*****@no-spm.please.zeeshan.net> schreef in bericht
news:OE**************@tk2msftngp13.phx.gbl... please post this question in this newsgroup: microsoft.public.dotnet.framework.adonet (news://news.microsoft.com/microsoft....amework.adonet)
-- Hope this helps, Zeeshan Mustafa, MCSD
"Richard" <ri*****@nospam.com> wrote in message news:40**********************@newsreader.eweka.nl. .. In normal asp i used ---------
objRS.Open "tbl_Nieuws", objConn, 1, 3 objRS.AddNew
objRS.Fields("N_Datum") = FormatDateTime(Now(),2) objRS.Fields("N_Title") = ReplaceHTML(Upload.Form("title")) objRS.Fields("N_Intro") = ReplaceHTML(Upload.Form("intro")) objRS.Fields("N_Body") = ReplaceHTML(Upload.Form("body")) objRS.Fields("N_UserID") = Upload.Form("id") objRS.Fields("N_Image") = file.Filename objRS.Fields("N_Ip") = strIP objRS.Fields("N_Deleted") = 0
objRS.Update IntID = objRS("N_ID") objRS.Close
--------- to get the id of the record i just added. in asp.net i have this but i dont know how i can accomplish the same and wanted to know if there is some easyway for it.
-----------------
Dim myConnection As New SqlConnection(AppSettings("DatabaseCon")) Dim strSQL As String = "insert into tbl_Users" & _ "(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code, U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned, U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _ "values('"& tbGebruikersNaam.Text & "'," & _ "'"& tbWachtwoord.Text & "'," & _ "'"& tbEmailAdres.Text & "'," & _ ""& strKlantenNR &"," & _ "'"& i & "'," & _ "1," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," &
_ "0," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," &
_ "0," & _ "'no_avatar.gif'," & _ "'"& strIP & "'," & _ "0," & _ "0," & _ "'"& strMSN & "')"
Dim MyCommand As New SqlCommand(strSQL, myConnection) myConnection.Open() MyCommand.ExecuteNonQuery() myConnection.Close()
-------------- i want the record of the record i just added to the tbl_Users. How 2? thats the question.
thx in advance,
Richard
you are right Richard, but see your question is about database
(ado in fact) so if you ask this question in adonet ng, there you'd
find more helpers dedicated for ado.net help.. this is a general
practice, the more accurate place you post your question,
the more quickly/well you'll be answered.
good luck :-)
--
Hope this helps,
Zeeshan Mustafa, MCSD
"Richard" <ri*****@nospam.com> wrote in message
news:40**********************@newsreader.eweka.nl. .. eeuh? Okay althrou i dont know why i cant ask the question here? its
asp.net as far i know.. :S
Richard
"M. Zeeshan Mustafa" <ze*****@no-spm.please.zeeshan.net> schreef in
bericht news:OE**************@tk2msftngp13.phx.gbl... please post this question in this newsgroup: microsoft.public.dotnet.framework.adonet (news://news.microsoft.com/microsoft....amework.adonet)
-- Hope this helps, Zeeshan Mustafa, MCSD
"Richard" <ri*****@nospam.com> wrote in message news:40**********************@newsreader.eweka.nl. .. In normal asp i used ---------
objRS.Open "tbl_Nieuws", objConn, 1, 3 objRS.AddNew
objRS.Fields("N_Datum") = FormatDateTime(Now(),2) objRS.Fields("N_Title") = ReplaceHTML(Upload.Form("title")) objRS.Fields("N_Intro") = ReplaceHTML(Upload.Form("intro")) objRS.Fields("N_Body") = ReplaceHTML(Upload.Form("body")) objRS.Fields("N_UserID") = Upload.Form("id") objRS.Fields("N_Image") = file.Filename objRS.Fields("N_Ip") = strIP objRS.Fields("N_Deleted") = 0
objRS.Update IntID = objRS("N_ID") objRS.Close
--------- to get the id of the record i just added. in asp.net i have this but i dont know how i can accomplish the same
and wanted to know if there is some easyway for it.
-----------------
Dim myConnection As New
SqlConnection(AppSettings("DatabaseCon")) Dim strSQL As String = "insert into tbl_Users" & _ "(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code, U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned, U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _ "values('"& tbGebruikersNaam.Text & "'," & _ "'"& tbWachtwoord.Text & "'," & _ "'"& tbEmailAdres.Text & "'," & _ ""& strKlantenNR &"," & _ "'"& i & "'," & _ "1," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"',"
& _ "0," & _ "'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"',"
& _ "0," & _ "'no_avatar.gif'," & _ "'"& strIP & "'," & _ "0," & _ "0," & _ "'"& strMSN & "')"
Dim MyCommand As New SqlCommand(strSQL, myConnection) myConnection.Open() MyCommand.ExecuteNonQuery() myConnection.Close()
-------------- i want the record of the record i just added to the tbl_Users. How 2? thats the question.
thx in advance,
Richard
Hi Richard,
As for the retrieving the new added record's identity problem. In ADO.NET,
if we use the DataSet and together with the DataAdapter component to manage
the data's insert, update , delete. For example, in vs.net , we create the
DataAdapter using the "DataAdapter Configuration wizard", there is an
advanced option called "Refresh the DataSet" which indicate that the
DataAdpater will add a Select statement after Insert and Update statements
to retrieve identity column values, default values and other values
calculated by the database. You can try draging a DataAdapter in VS.NET to
have a look.
If you don't use DataSet and DataAdapter , just use simple SqlCommand
object to execute sqlstatement, I'm afraid, the only means to rerieve the
identity of the new added record is to execute a select query after the
insert statement to retrieve the identity.
IN addition, here are some former threads in the group discussing on the
similar problem: http://groups.google.com/groups?hl=e...RYxGtBHA.2552%
40tkmsftngp04&rnum=5&prev=/groups%3Fq%3Dado.net%2Bget%2Bnew%2Brecord%2Bident
ity%26ie%3DUTF-8%26hl%3Den http://groups.google.com/groups?hl=e...b01c275c5%24f6
7a9130%2437ef2ecf%40TKMSFTNGXA13&rnum=19&prev=/groups%3Fq%3Dado.net%2Bget%2B
new%2Brecord%2Bidentity%26hl%3Den%26lr%3D%26ie%3DU TF-8%26start%3D10%26sa%3DN
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tony Stoker |
last post by:
I have a .Net web app that adds a record to a SQL
database. After the user adds their record I want to
have a link that will link them to their new record! The
recordID is a AutoNumber in the...
|
by: Tony |
last post by:
Thanks for writing back and don't laugh at what I am
about to post I am new to this type of stuff....this is
what I have tried and it isn't working(please note in the
try section I was just trying...
|
by: sara |
last post by:
Hi
I'm pretty new to Access here (using Access 2000), and appreciate the
help and instruction.
I gave myself 2.5 hours to research online and help and try to get this
one, and I am not getting...
|
by: thomasp |
last post by:
I am using the following code to add a record to an Access database. If I
run the code and go to the database the code is there, but if as soon as I
run the code I try to access the record with...
|
by: AA Arens |
last post by:
Hi,
I have a database with 2 main forms. Contacts and companies. I share
the base with two others via LAN. On the companies form I have buttons
to navigate throught the records
(>400). We are...
| |
by: nch1978 |
last post by:
I am new to programming and am sorry if this post is in the wrong area. I have a listbox bound to a table and a datagrid bound to another one with a connection through xml. I can change the data...
|
by: MLH |
last post by:
Suppose, in a multi-user environment, you
have append query SQL in a VBA procedure
that looks like INSERT INTO MyTable...
and the next line reads MyVar=DMax("","MyTable...
You can never be...
|
by: =?Utf-8?B?SmFtZXM=?= |
last post by:
Hello all,
I have this idea that might not work, our website is built by someone else
and is a CMS website. There is a page with links to other websites and at the
moment I have created a file...
|
by: sparks |
last post by:
I have always just got a count on records and put up a box at the top
of the entry forms saying something like 1 of 500 and updating it as
you got to 500 of 500.
I have never thought of this as...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |