|
I have something but it's not quite right, because years ending with 00 before de decimal are not leap years (example 1700 1800 1900 or even 2000000 as long as it has 00) I don't know how to do that. Also thanks for your help Guffa.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim y As Integer
y = TextBox1.Text
If y Mod 4 = 0 Then
TextBox2.Text = "is leap"
ElseIf y Mod 400 = 0 Then
TextBox2.Text = "is leap"
Else
TextBox2.Text = "isn't leap"
End If
End Sub
|
|
|
|
|
Nevermind I got it
|
|
|
|
|
Hi,
I have a generic class to persist any kind of object to a SQL table using PropertyInfo.GetValue to read the values - but it doesn't work if the property is a Nullable(Of ...) type and the value is not set - I get a "Nullable value must have a value" error.
Any ideas how I can modify
Dim val As Object = PropertyInfo.GetValue(ClassInstance, Nothing)
so it can cope with empty nullable types?
Thanks in advance
|
|
|
|
|
I need help in MYSQL and VB.NET.
How can i insert the datetime of my computer into Sql database?No mater how i convert the date, it does'nt work.
Here is the code:
Dim PurDate As Date
PurDate = Date.Now()
Dim strInsSales As String
strInsSales = "Insert into Testing Values(" & PDate & ")"
And the value store into SQL is "1900-01-01 00:00:00.000"
Anyone can help me in this problem?
|
|
|
|
|
There are two errors in the code. You have forgotten the apostrophes around the value, and you are not using the same variable as the one that you put the value in. Also, you should specify a format when converting the date to a string, not just using the default format, as that can be juat about anything.
strInsSales = "Insert into Testing Values('" & PurDate.ToString("yyyy-MM-dd HH:mm:ss") & "')"
Better yet, you should use a parameterized query.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks Guffa, i hv solve d the problem right now.
However, another problem is occured.
After i insert the date into Sql database, then i need to retrieve the date and compare with the user input's date.
Dim SDate as string
SDate = year & "-" & month & "-" & day
Eg: user input is : 2006-10-22
Also, SqlDate is : 2006-10-22 23:59:52.000
SDate = Convert.ToDateTime(SDate).ToShortDateString
SqlDate = Convert.ToDateTime(SqlDate).ToShortDateString
If (SDate = SqlDate) Then
valid = True
End If
However, it give me a false value, even the date are equal.
How should i solve this problem?
Thanks again...
|
|
|
|
|
Hi there,
On the SDate Variable, you can use the format method from VB6 class to truncate the time such as
Vb6.format(SDate,"yyyy-mm-dd")
Have a happy coding
|
|
|
|
|
Thanks paulajohn, i have solved the problem!
|
|
|
|
|
any one know how to make an application that can run without .net framework?
|
|
|
|
|
xmen_xwk wrote: any one know how to make an application that can run without .net framework?
You can't while you are using VB.NET or C# out of the box. (There are some very expensive solutions that will "static" link .NET)
If you want to write an app that doesn't use the .NET framework, then you'll need to use VB6 or unmanaged C++.
|
|
|
|
|
ok
|
|
|
|
|
Hello,
I have a program that when a user logs in they will only be able to do certain things based on there user privilege. Example, low, medium, and full access.
If the user has low then they can only view, if the use has medium they can edit and add, if they have full then they can do everything.
The buttons will be disabled for actions that they cannot do.
In the database, i have entered their privileges as low, med, or full.
I am not sure if this is the best way to do this, but before each form is loaded, i check there privileges by quering the database. Then disabling button based on their user privilege.
As this is my first time i have done this, I would like to know how this is done in the real world. Is there is a more efficient method of doing this.
Many thanks in advance,
Steve
|
|
|
|
|
Hi Steve,
This is right approach.
In form load you have to check from database depending on user access rights, you can disable or invisible buttons.
Best Regards,
S Kumar
|
|
|
|
|
Hello,
Thanks for your answer, I wasn't sure about this. However, all those calls to the database might slow the program down.
I was thinking about setting a global variable in a class that is assigned their privilege from when they log in. Each form will just check from this global variable.
Thanks,
Steve
|
|
|
|
|
steve_rm wrote: Thanks for your answer, I wasn't sure about this. However, all those calls to the database might slow the program down.
I was thinking about setting a global variable in a class that is assigned their privilege from when they log in. Each form will just check from this global variable.
A lot depends on how much security you want in your app. Most of my internal applications, load the users profile settings at start-up and then I check the "global" profile object to find the permissons when needed. To add a bit more security, I reload the settings from database after an x number of minutes/form loads, just incase the users settings have been changed whilst they are in the app. It is a case of balancing speed of use against security.
|
|
|
|
|
Hello,
Thanks for your advice.
I was thinking of gettng there the privilege from when they log in and having that in a global variable.
However, I would like to do this in a very professional way that is both efficient and scalable. Is is possible to have groups of permissions and then assign a person to this group. Something that is very simliar to SQL Server.
Do you know of any online tutorials?
Thanks in advance,
Steve
|
|
|
|
|
In vb.net ,i have two forms.
in the first form progress bar and command button are added.
the second form contains a sqladapter,sqlconnection,dataset and a datagrid.
When click the command button in form1 ,the loading time of the form2 and database connection should be shown by the progress bar
|
|
|
|
|
Hi,
In form2, you can use code like form1.progressbar.value = 10 (some value depends on your procedure or function calls)
at last you can write
form1.proressbar.value = 100
Regards,
S Kumar
|
|
|
|
|
Hi there,
I am afraid that you can't do it because how do you know when the SQLadater finishes loading data into dataset.
There is only trick to do to this case is: after the SQLAdapter finished filling the dataset then you can use the counter to count the record in datatable and increase the progress bar by the count. when the iteration loop reach the last record then you can bind the grid to the datatable. However your users have to wait double times which might not be worth to add this fancy bell and wishle.
Have a happy coding
Paula
|
|
|
|
|
Hello VB.NET users,
I am very much new here. I have created 2 forms, form1 and form2. Each contains data grid. When the user in the form1-Datagrid say 7 the coulmn clicked the form2 with datagrid should open. When the user selects values from form2 pointer should go back to 7th coulmn and value should populate from form2(datagrid).
Please give me source code to my email address arun@albahar.ae
Regards
arun
|
|
|
|
|
Hi all,
I got a really big problem here. I am using VS.2005 to build our website.
How can i clear a seperate table when i close an application???
Shall i write the code in the Global.asax ??? just under the Application_End event!!
Or i can do something else to solve this problem???
Please help !!!
It is really urgent to me!!!
thanks
Jackie Ding
|
|
|
|
|
Hi Jackie,
Are you talking about database table, if yes then next time when user logs in that you can clear that table.
Regards,
S Kumar
|
|
|
|
|
Thanks Kumar,
Yes, I was talking about the Sql Database, and i store a list of product attributes in a seperate table, but this table is for users that haven't logged in yet. (i use this table just like use Cookies, but i don't use Cookies to store those information).
I was using "Application("ActiveUser")" to give each user that visits our website a sessionID, and then store something they choose in this seperate table, what i am doing is trying to delete all records belongs to a sessionID once the user leaves our website.
Please Help, thanks
Jackie Ding
|
|
|
|
|
Hi Jackie,
Your application might be like online shopping and users like Guest user.
If yo can keep track of signoff or logout then you can put that part of code in this code.
You can write code in session end of global.asax.
Regards,
S Kumar
|
|
|
|
|
Hi Kumar,
You are right, I am dong an online shoppingcart project.
I was trying to write code in session-end, but i really didn't how to write it. So could you please help??
i am trying to keep the session id increase by 1 each time, so that each user, even he hasn't login yet, can be seperated from other users, but the annoying thing is the session just repeat it again and again. For example, i run the website, and put something into a shoppingcart, and then leave without paying the money, and i do it for several times, but then the session number just start from 1 again, so the shopping cart doesn't only include current user's thing, but also the previous one's thing.
Now i am really really sad about it......, but still have no idea to fix it.
Have you got a MSN, I really need your help now, cause i am really in a hurry.
Please, Thanks
Jackie Ding
|
|
|
|