connectToDatabase()
openConnection()
incrementmoni()
Try
Dim i As Integer
i = command.ExecuteScalar()
lbllog.Text = i.ToString + 1
Catch ex As Exception
End Try
closeConnection()
Sub incrementmoni()
command = New SqlCommand("select max(Monitor_Number) from tbl_monitor", connection)
adapter.SelectCommand = command
End Sub
Max() function stops at 10
Page 1 of 110 Replies - 775 Views - Last Post: 04 October 2012 - 12:51 PM
#1
Max() function stops at 10
Posted 04 October 2012 - 06:24 AM
Hi I'm using max() function to set auto_increment in database but the problem is it stops adding when it reaches 10. Upon it reaches 10 all the columns after that will be 10 , i have this code
Replies To: Max() function stops at 10
#2
Re: Max() function stops at 10
Posted 04 October 2012 - 07:40 AM
your code only fetches the number, but does not set it. besides that, if you have an autoincremented column, why set the number manually?
#3
Re: Max() function stops at 10
Posted 04 October 2012 - 09:36 AM
Hi Dormilich, i can increment it from 1 upto 10 but after that next number will be 10, and i cant set the column in auto increment since im using the my sql built in withing the visual studio 2008. That's why i use this method. Just to add up my question how can i determine if the column is null? so i make the label as 1 to start.
#4
Re: Max() function stops at 10
Posted 04 October 2012 - 10:39 AM
could you post your table setup?
#5
Re: Max() function stops at 10
Posted 04 October 2012 - 11:51 AM
what you mean by setup? the table definition? sorry I don't have the laptop with the program. The columns looks like this Auto_ID, Student_Number , Fname , Lname , Mname . But to be honest i really don't want to use the max function if i can use the auto increment method in database.
#6
Re: Max() function stops at 10
Posted 04 October 2012 - 12:31 PM
yes, the table definition.
but I don’t understand, how a getter function like MAX() is supposed to set a field value.
but I don’t understand, how a getter function like MAX() is supposed to set a field value.
#7
Re: Max() function stops at 10
Posted 04 October 2012 - 12:35 PM
I just use max to get the highest value in Auto_ID column then put it in a label as integer then add +1 yea it can cause auto increment but when it reaches 10 it stop i think I'm missing something like it can only read 1 digit number
#8
Re: Max() function stops at 10
Posted 04 October 2012 - 12:36 PM
maybe the data type of the column is wrong?
#9
Re: Max() function stops at 10
Posted 04 October 2012 - 12:44 PM
Sure ill check it then post what i got. Btw can i ask another question? Example I have a table like this
Auto_ID Name Status
1 apple In
2 apple Out
4 apple In
5 Mango In
i want to select all name with "In" Status i tried to use select name from table where value = in
but returns 2 apple and 1 mango. But i just want to get the latest In of apple and count it as 1
so the it will give me apple and Mango only
Auto_ID Name Status
1 apple In
2 apple Out
4 apple In
5 Mango In
i want to select all name with "In" Status i tried to use select name from table where value = in
but returns 2 apple and 1 mango. But i just want to get the latest In of apple and count it as 1
so the it will give me apple and Mango only
#10
Re: Max() function stops at 10
Posted 04 October 2012 - 12:46 PM
if you only want the name, use SELECT DISTINCT.
#11
Re: Max() function stops at 10
Posted 04 October 2012 - 12:51 PM
I need all the columns because i will display it in a datagridview. But no worries i can do the display only the selection of data from database
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|