(small question - big help)... i have some web form that handle digital print order from website that fill by the company customers. the form including some information about the customer, print information and upload files. After the customer ending fill the form and click send there is a code (using C# + SQL + ADO.NET) that handling the request. first the information checked, then inserting into the sqlexpress database and finally (with smtp client code) sending to the owner of the site that is a new order waiting for him and this mail including all the information the customer fill + all the files his uploaded. The question is: because all the information is fill by the customer i dont have problem to "call" that information (by: name.text, phone.text and so on...) but the orderID (which is the identity number and increment by +1 each time automaticlly by the database) is not something the customer fill. how can i "call" this number to the smtp mail sending?

After you have inserted the values in the database the orderid will be automatically generated. Just call it after the insert query is executed.

thanks for replay.... i know this is what i need to do i just don't know exaclly how to do it..... :-)

have u tried it yet?
if yes post the code so that i can help u..

I didn't try yet cause i cant think of any way to do this.... i can send you the code (its a little bit looooooong one)

OK thanks a lot...

Firstly, whenever you post code just wrap it between code tags.
Secondly, I can help u with the logic. Try it..if it still doesn't work then tell me..
After u have executed the insert query,the orderid will be generated for that inserted entry. Now, give another query for selecting that orderid.

After you insert the record you can get the auto incremented record number by using: SCOPE_IDENTITY() in MSSQL. Second this is a design change from what you have, but how it should work:

Create a table in the MSSQL Database:

Create Table YourTableName
(
  RecordId int,
  CustName varchar(50),
  Emailed bit
)

Next after the customer hits "Send me an email" you should insert a record in to that table. You should write a windows service to check for any record with "Emailed = 0 or Emailed Is Null" and send emails to those customers. You don't want a "button click" to truly send out an email because what if you wanted to suspend email delivery for 2 hours while the mailserver is down? With your current design you would be screwed. With this design it can handle the situation! :)

Lastly after an email is sent you would set "Emailed = 1" so you would know not to reprocess the row.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.