AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > how to autogenerate jobno when i open a new form and display in the form jobno field

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 11/6/2006
Subject: how to autogenerate jobno when i open a new form and display in the form jobno field

Question
i have the code but i really dono how to write it correctly
below are the code i wrote out
Sql = "SELECT MAXJobNo " & _
                       "FROM prodjof WHERE JobNo LIKE AS06 + """
myCommand.Connection = conn
       If JobNo Is DBNull.Value Then
           strJobNo = "00001"
       Else
           strJobNo = strJobNo + 1
       End If
       strJobNo = "AS06" + strJobNo


-------------------------------------------
The text above is a follow-up to ...

-----Question-----
i have noy write it yet coz i dono how to write it..can u help me with this . yhx
-------------------------------------------
The text above is a follow-up to ...

-----Question-----
Dear sir,
Can u explain in more details and how to write the code....thx
-------------------------------------------
The text above is a follow-up to ...

-----Question-----
i am using vb.net 2005 and mysql as databse to create my project.

i have jobno field in my form that i want it to autogenerate the number when i open the form. when i open the form the jobno autogenerate and display in my jobno field. my jobno is like AS06000001 n i want the 000001 to autogenerate and increse when open the form. COuld anyone help me please...thx

-----Answer-----
Dear Elizabeth,
You need to query the database for last ID in the table you can use e.g. Select Max(JobNo) from tblJobs to retrieve the last job no. and then add 1 to it and display it. All needs to be done on form's load event.

Regards,
Rizwan
-----Answer-----
Dear Elizabeth
what exactly do you want to know, please be specific otherwise my rant can become really annoying. Have you written any code yet for this problem?

Regards,
Rizwan
-----Answer-----
if you can send me your code with this problem I can tell you how to fix, try to establish a basic form first which can read data from my sql, test it and then paste the code here then I will tell you how to fix it.

Answer
its max(jobno) not maxjobno
and you need to execute a jobno = cmd.executescalar to retrieve the maximum job no. then you can say numjob = jobno.replace("AS06","") this is to remove the alphabatical part and then say numjob = numjob + 1 to create a next job no. and then say newjobno = "AS06" & numjob. you will face some glitches when you get this working thats all part of learning :)

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.