| | |
AutoNumber still a problem !! can ne1 clear the mess?
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
I am really at my wits end now....i am unable to find ne proper code for autonumber generation...if i do find its not working. plz i want it ..i am using sql server 2000 and vb.net 2005.
just tell me can we make use of max function ?
ie. first get the max of id and then increment it by 1 ?
like ("select max(id) from tablename)
and then txtbox.text=id+1
however i encounter several errors here...can we do autonumbering this way ??? ne ideas ?
plz help me out....'coz of this am unable to complete my project work...
wating for ur reply
cya
Rohan
just tell me can we make use of max function ?
ie. first get the max of id and then increment it by 1 ?
like ("select max(id) from tablename)
and then txtbox.text=id+1
however i encounter several errors here...can we do autonumbering this way ??? ne ideas ?
plz help me out....'coz of this am unable to complete my project work...
wating for ur reply
cya
Rohan
Try This :
Generate will shown in txtNoNota
vb.net Syntax (Toggle Plain Text)
Public Sub GenerateNotaId() Dim myReader As SqlDataReader conn = GetConnect() conn.Open() Dim temp As String Try Dim sql As String = "SELECT MAX(IDNOTA) AS 'KODE' FROM Nota " Dim comm As SqlCommand = New SqlCommand(sql, conn) myReader = comm.ExecuteReader If myReader.HasRows Then While myReader.Read() temp = myReader.Item("KODE") + 1 End While End If myReader.Close() Catch ex As Exception End Try conn.Close() If temp = 0 Then txtNoNota.Text = 1 Else txtNoNota.Text = String.Concat(temp) End If End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
thanks but still getting an error ! can u plz tell which files to import ???
•
•
•
•
Try This :
Generate will shown in txtNoNotavb.net Syntax (Toggle Plain Text)
Public Sub GenerateNotaId() Dim myReader As SqlDataReader conn = GetConnect() conn.Open() Dim temp As String Try Dim sql As String = "SELECT MAX(IDNOTA) AS 'KODE' FROM Nota " Dim comm As SqlCommand = New SqlCommand(sql, conn) myReader = comm.ExecuteReader If myReader.HasRows Then While myReader.Read() temp = myReader.Item("KODE") + 1 End While End If myReader.Close() Catch ex As Exception End Try conn.Close() If temp = 0 Then txtNoNota.Text = 1 Else txtNoNota.Text = String.Concat(temp) End If End Sub
This some files to import :
what kind of error ??
vb.net Syntax (Toggle Plain Text)
Imports System.Data Imports System.Data.SqlClient
what kind of error ??
Last edited by Jx_Man; Sep 1st, 2008 at 9:51 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
error like getconnect() not defined.....?
[
QUOTE=Jx_Man;682207]This some files to import :
what kind of error ??[/QUOTE]
[
QUOTE=Jx_Man;682207]This some files to import :
vb.net Syntax (Toggle Plain Text)
Imports System.Data Imports System.Data.SqlClient
what kind of error ??[/QUOTE]
getconnect() is Function to connect to sqlserver.
put this code in module. my module named Koneksi
put this code in module. my module named Koneksi
vb.net Syntax (Toggle Plain Text)
'In Module 'Declare outside of class Imports System.Data Imports System.Data.SqlClient Module Koneksi Public conn As SqlConnection Public Function GetConnect() conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes") Return conn End Function End Module
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
IS THIS CODE WORKING FOR U ???
THOUGH I AM NOT GETTING ANY ERROR NOW IN THE CODE, WHEN I RUN I GET ID AS 1 IN MY ID BOX , HOWEVER , WHEN I INSERT A RECORD , THEN THE NUMBER IS NOT INCREMENTED TO NEXT RECORD....EVEN IF I LOAD MY FORM AGAIN I SHOULD GET TO SEE THE NEXT NUMBER BUT IT STARTS AGAIN FROM 1, THAT VIOLATES MY PRIMARY CONSTRAINT.......WHTS THE PROBL ????
I AM NOT UNDERSTANDING WHY THE AUTO GENERATE FACTOR IS GETTING SO LONG TO BE SOLVED AT MY END.....PLZ CLARIFY SOON !
AWATING RESPONSE
THOUGH I AM NOT GETTING ANY ERROR NOW IN THE CODE, WHEN I RUN I GET ID AS 1 IN MY ID BOX , HOWEVER , WHEN I INSERT A RECORD , THEN THE NUMBER IS NOT INCREMENTED TO NEXT RECORD....EVEN IF I LOAD MY FORM AGAIN I SHOULD GET TO SEE THE NEXT NUMBER BUT IT STARTS AGAIN FROM 1, THAT VIOLATES MY PRIMARY CONSTRAINT.......WHTS THE PROBL ????
I AM NOT UNDERSTANDING WHY THE AUTO GENERATE FACTOR IS GETTING SO LONG TO BE SOLVED AT MY END.....PLZ CLARIFY SOON !
AWATING RESPONSE
•
•
•
•
getconnect() is Function to connect to sqlserver.
put this code in module. my module named Koneksi
vb.net Syntax (Toggle Plain Text)
'In Module 'Declare outside of class Imports System.Data Imports System.Data.SqlClient Module Koneksi Public conn As SqlConnection Public Function GetConnect() conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes") Return conn End Function End Module
>> IS THIS CODE WORKING FOR U ???
Yes...Its working for me.
>> WHEN I INSERT A RECORD , THEN THE NUMBER IS NOT INCREMENTED TO NEXT RECORD
Call that procedure after inserting data
>> EVEN IF I LOAD MY FORM AGAIN I SHOULD GET TO SEE THE NEXT NUMBER BUT IT STARTS AGAIN FROM 1, THAT VIOLATES MY PRIMARY CONSTRAINT
Check your database. If your data was inserted then it should working.
And please don't use capital letters. I am trying to help you.
Yes...Its working for me.
>> WHEN I INSERT A RECORD , THEN THE NUMBER IS NOT INCREMENTED TO NEXT RECORD
Call that procedure after inserting data
>> EVEN IF I LOAD MY FORM AGAIN I SHOULD GET TO SEE THE NEXT NUMBER BUT IT STARTS AGAIN FROM 1, THAT VIOLATES MY PRIMARY CONSTRAINT
Check your database. If your data was inserted then it should working.
And please don't use capital letters. I am trying to help you.
Last edited by Jx_Man; Sep 2nd, 2008 at 6:05 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
thanks a lot buddy ! problem is solved
•
•
•
•
>> IS THIS CODE WORKING FOR U ???
Yes...Its working for me.
>> WHEN I INSERT A RECORD , THEN THE NUMBER IS NOT INCREMENTED TO NEXT RECORD
Call that procedure after inserting data
>> EVEN IF I LOAD MY FORM AGAIN I SHOULD GET TO SEE THE NEXT NUMBER BUT IT STARTS AGAIN FROM 1, THAT VIOLATES MY PRIMARY CONSTRAINT
Check your database. If your data was inserted then it should working.
And please don't use capital letters. I am trying to help you.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Start Sub in 5 seconds
- Next Thread: Code error.....plz rectify me :)
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse editvb.net employees excel exists filter forms function html images isnumericfuntioncall listview map mobile module msaccess mssqlbackend mysql net number open page pan panel pdf picturebox picturebox2 port position print printing printpreview read record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winsock wpf wrapingcode xml year






