|
hello every one
i want to generate one of the field of database as auto increment in my project for that i wrote code as:- 'database is in Sqlserver 2005'
Dim newid As Integer=Val(obj.getvalsfrmtbl("select max regi_code from regi_mast")) +1
Me.txt4.Text = newid
Me.txt4.Enabled = False
where obj.getvalsfrmtbl is a function in class for getting one by one values from database... like
Public Function getvalsfrmtbl(ByVal str) As String
Try
Dim res As String = ""
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
If dr.HasRows = True Then
dr.Read()
res = dr.Item(0)
Else
res = ""
End If
dr.Close()
cn.Close()
Return res
Catch ex As Exception
Return 0
Finally
cn.Close()
End Try
End Function
to this i got solution like
Public Function getvalsfrmtbl() As Integer
Try
Dim res As Integer
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
Dim cmd As New SqlCommand("select max(regi_code) from regi_mast", cn)
cmd.CommandType = CommandType.Text
Dim dr As SqlDataReader
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
If dr.HasRows = True Then
dr.Read()
res = CInt(dr.Item(0))
Else
res = 0
End If
dr.Close()
cn.Close()
Return res
Catch ex As Exception
Return 0
Finally
cn.Close()
End Try
End Function
Dim newid As Integer = Val(obj.getvalsfrmtbl()) + 1
Me.txt4.Text = newid
Me.txt4.Enabled = False
but this is not true for database having more then one table ..
so what shall i do
please help.....
|
|
|
|
|
Hi,
I trust the notion of "auto-increment" appears in each and every SQL manual.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
This is the same question you asked 6 hours ago. Don't spam the boards with the same question.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi all,
I am doing a School Management project in VB.Net and backend as MySql.. In that we have to use a calendar to show the list of holidays, absent students list, add an events etc.,.( it should be like Google calendar)
I am trying with Month Calendar, Is there any option to Increase the size of the calendar and the cells of the calendar?
Please help me...
Thanks
VVV
VB.Net
|
|
|
|
|
AFAIK, no. You'll have to make your own custom control. It isn't that difficult; you could probably get away with using a Panel. Get the month, use that to get the number of days. Iterate from 1 to number of days, dynamically create a control and add it at the previous control's position, plus a little for padding and the size of the previous control
|
|
|
|
|
Hi,
thanks for the reply..
But i didnt get u.. can u please give me a detailed information on this.. y bcoz i am new to .Net..
Thanks in advance
Victoria
VB.Net
|
|
|
|
|
Try not to use text speak, bcoz should be because and y is why.
|
|
|
|
|
Thanks for your suggestions.
VB.Net
|
|
|
|
|
Okay, I'll break this down for you:
Create a custom control, and add a label. Put the month name in it
Get the number of days
For every day, create a label with the text being that day number. Add it to the custom control
Those controls you added can be wired up to a common event handler. Cast sender to a Label
|
|
|
|
|
Hi,
Thank You.. I Will try it out.. If i got any doubt or strucked somewhere i will put the message..
Victoria
VB.Net
|
|
|
|
|
Hi,
You told that, for every day create a label and add those labels to custom control right. Then where can i create those labels.. Is that in normal windows form? I am trying to create those labels in the custom control itself.. But that custom control form is not visible in the Solution Explorer Properties, to directly run that particular form only.
Thanks,
Victoria
VB.Net
|
|
|
|
|
Hi,
I am in framework 1.1 of vb.net. If I click a row, which is in the data grid, I want to change the entire row back ground color. How I can do?. tnx in adv.
Balasubramanian K.
|
|
|
|
|
In the CurrentCellChanged event, get the CurrentRowIndex property of the DataGrid. Then, iterate every row; if the row index is equal to CurrentRowIndex, set the background colour to the colour you want. Otherwise (and this is important), reset the background colour to your default
To set the background colour of a row, just set the DataGrid.SelectionBackColor property
|
|
|
|
|
Yah. Thank you
Balasubramanian K.
|
|
|
|
|
in my website i have to folders. in that two folders i put two web.config files for each one.
And in root folder i put another web.config file in that i write below code
<authentication mode="Forms">
<forms name="auth" loginurl="./pages/Userlogin.aspx" defaulturl="./pages/UserVotings.aspx">
Now i want to user this authentcation in above two folder but. here.
for folder1 i have different login url and defaulturl.
and for folder2 i have different login url and default url.
how to apply root web.config to those to folders web.config
|
|
|
|
|
hello every one
I am having problem with increment, I want that regi_code declared below should be auto increment for that I
I am using SQLServer 2005 as my back end.
I wrote code as :-
Dim newid As Integer = Val(obj.getvalsfrmtbl("select max(regi_code) from regi_mast")) + 1
Me.txt4.Text = newid
Me.txt4.Enabled = False
now the problem is it returns me value "1"
this obj.getvalsfrmtbl is a function declared in class for getting one by one values from database
eg:=
Public Function getvalsfrmtbl(ByVal str) As String
Try
Dim res As String = ""
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
If dr.HasRows = True Then
dr.Read()
res = dr.Item(0)
Else
res = ""
End If
dr.Close()
cn.Close()
Return res
Catch ex As Exception
Return 0
Finally
cn.Close()
End Try
End Function
if same thing i do with access as bac kend it worked but I need it to work with SQLServer 2005..
so, please help me....
I am beginner....
|
|
|
|
|
You have not set the CommandText for the SQLCommand object.
|
|
|
|
|
Public Function getvalsfrmtbl() As Integer
Try
Dim res As Integer
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
Dim cmd As New SqlCommand("select max(regi_code) from regi_mast", cn)
cmd.CommandType = CommandType.Text
Dim dr As SqlDataReader
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
If dr.HasRows = True Then
dr.Read()
res = CInt(dr.Item(0))
Else
res = 0
End If
dr.Close()
cn.Close()
Return res
Catch ex As Exception
Return 0
Finally
cn.Close()
End Try
End Function
just try this code in your class
and in you front end coding write this code
Dim newid As Integer = Val(obj.getvalsfrmtbl()) + 1
Me.txt4.Text = newid
Me.txt4.Enabled = False
|
|
|
|
|
thank u
very much..
|
|
|
|
|
Haii..
Camne erk sy nk cetak maklumat dlm database melalui vb??
|
|
|
|
|
Please use English language. Not all can get what you have posted.
|
|
|
|
|
Credo che sia possibile, devi consultare la documentazione...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i need code for printing the contents of labels and text box in printer by manually setting the page oriantation as landscape or potrait in vb .net
|
|
|
|
|
First you need to understand this[^].
|
|
|
|
|
I'd recommend buying a book, learning at your own pace, and not accepting paid work until you have some sort of skill set.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|