Check your database connection....
When you want to test first see that the result is visible in your main report preview window....
show the code if you have added...
Check your database connection....
When you want to test first see that the result is visible in your main report preview window....
show the code if you have added...
In the key press event of the text box try writing the below code....it will allow user to enter only number and when the user will enter alphabet or any other characters it wont allow user to enter it....
'accepts only numbers
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
Login form is different and user registration is different
Login form-
Create a form with the basic requirements like
two labels as username and password....
two textboxes for entering username and password
three buttons for login, closing form and one for reset....
Make the database connection....
Validate if the user is there in database and then login else error msg box
User Registration-
First make sure of the requirements of the user like firstname, lastname, email, username, password, confirm password....
Validation for email, check username if already in database, strong password if required....
creating new users....
database connection insert query
deleting users....
database connection
delete user according to username....
As soon as u create the file, it is in open state....u need to close the object of the file and then try to load the data...
FileClose()
u need a read method...the reader is not able to read the data....
u r not using the read method and u are trying to get the values....that is why u are getting this error
try this
icon.setIconImage(image);
Just an idea...
I had to save the data as INP1 - first 3 characters and last integer
We cant save the alphanumeric as integer
but what I had done was....I had one temp table....which had the integer value...
every time I need to increment the value I used to check the value in that table and update in my new table....that had datatype as varchar...so everytime it used to get incremented correctly....after the insert statement then update the temp table by 1....
or in place of server can also add localhost....
to check ur server name u can use a query
select @@SERVERNAME
'connection string
Connection.ConnectionString = "Data Source = LocalHost\;Initial Catalog = DatabaseName;Integrated Security = True"
Can you just show ur code....
what is the datatype??...if the datatype is varchar / text it wont increment beyond 10....same had happened with me....
I had to take int as the datatype and then increment it....
this database backup will get created on basis of date....u can also use Application.Startup path or any dynamic path that needs to be created....
Try
If Not Directory.Exists("D:\" + Date.Today.ToString("dd.MM.yyyy") + "\Backup") Then
Directory.CreateDirectory("D:\" + Date.Today.ToString("dd.MM.yyyy") + "\Backup")
End If
Dim MySQL_Connection As SqlConnection = New SqlConnection()
MySQL_Connection.ConnectionString = "Data Source = LocalHost;Initial Catalog = Test;Integrated Security = True"
MySQL_Connection.Open()
Dim myCommand As SqlCommand
myCommand = New SqlCommand(" BACKUP DATABASE [Test] TO DISK =N'D:\" + Date.Today.ToString("dd.MM.yyyy") + "\Backup\Test_full.bak' WITH FORMAT ", MySQL_Connection)
myCommand.ExecuteNonQuery()
myCommand = New SqlCommand(" BACKUP DATABASE [Test] TO DISK = N'D:\" + Date.Today.ToString("dd.MM.yyyy") + "\Backup\Test_diff.bak' WITH DIFFERENTIAL ,FORMAT ", MySQL_Connection)
myCommand.ExecuteNonQuery()
MsgBox("Backup Successfull")
MySQL_Connection.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Since the datatype is number in ur access database the value returned to ur textbox will be 0...if u remove the default value for ur datatype number in the database it wont return any value...
Make it blank to get the text box value as blank
if so then to run a command when the 'OK' button is pressed u can do the following
If MsgBox("Password successfully changed", MsgBoxStyle.OkCancel, "Attention") = MsgBoxResult.Ok Then
'some action
else
'some acction
End If
since it is a web browser ur msgbox is client side and the window.alert will be for the server side....
try using server side msgbox...
To take back up in .bak extension file
1. Right click on ur database name
2. Tasks -> back up -> Set the backup location and then click on OK.
To restore the .bak extension file
1. Right click on ur database name
2. Tasks ->Restore -> Database
3. Set the database name if the textbox is empty
4. Source for restore -> From database / from device
5. if from device...select the radio button and then click on browse
6. Click on Add -> then select the .bak file from ur correct path
7. Clck OK
8. Select the check box of the appropriate database from the list and click OK.
if u want to add the same in code...then do the following
Try
If Not Directory.Exists("D:\Backup") Then
Directory.CreateDirectory("D:\Backup")
End If
Dim MySQL_Connection As SqlConnection = New SqlConnection()
MySQL_Connection.ConnectionString = "Data Source = LocalHost;Initial Catalog = Datasourcename;Integrated Security = True"
MySQL_Connection.Open()
Dim myCommand As SqlCommand
myCommand = New SqlCommand(" BACKUP DATABASE [Datasourcename] TO DISK = N'D:\Backup\Datasourcename_full.bak' WITH FORMAT ", MySQL_Connection)
myCommand.ExecuteNonQuery()
myCommand = New SqlCommand(" BACKUP DATABASE [Datasourcename] TO DISK = N'D:\Backup\Datasourcename_diff.bak' WITH DIFFERENTIAL ,FORMAT ", MySQL_Connection)
myCommand.ExecuteNonQuery()
MySQL_Connection.Close()
Catch ex As Exception
Msgbox(ex.message)
End Try
Actually I dont know about the other two formats....
is it a vb.net msg box or a script to show the window.alert("")
Could you please tell how the reputation points increases???
Even after posting threads to help our daniweb friends or when others mark the thread as solved or even vote us up I dont find my reputation point increasing....
There is a joy within us when we see that the thread is marked as solved and the reputation points also increase, if we have helped someone....
But if it does not happen that interest could be lost....
This is not only for newbies but also the existing members....
this is according to my experience....I just feel the joy and the enthusiasm to post threads to help others....
The site is excellent for me to surf and find everything handy....
u can also do a select query with ur username and email in where condition and then if the reader is true then set the msg as already exists or allow the user for registration....
Below code is just to present u an idea....
Try
Dim MySQL_Connection As SqlConnection = New SqlConnection()
MySQL_Connection.ConnectionString = "Data Source = LocalHost;Initial Catalog = database;Integrated Security = True"
MySQL_Connection.Open()
Dim mysqlCommand As SqlCommand
mysqlCommand = New SqlCommand("SELECT PATIENT_ID FROM Patient_Reg WHERE PATIENT_ID='" + txtPatientID.Text + "'", MySQL_Connection)
Dim DBReader As SqlDataReader = mysqlCommand.ExecuteReader
If DBReader.Read = True Then
Msgbox("patient already exists")
else
'insert query
End If
Catch ex As Exception
Msgbox(ex.message)
End Try
To do the print preview part u need to add the print priview control or Dialog on ur form....
Please be more clear and precise....
If login is ur startup form u cannot close it else ur application will be closed...
set the form as hide or visible false before showing the other form....
and then show ur main form
Could u tell the format how u should get 130102 ???
Still confused with ur requirement....
Static methods can not directly access any instance variables or methods but they can access them by using their object reference.
Static methods may even access private instance variables via a object reference.
All private instance variables are private to its class, they can be accessed by static methods or non-static method of the class.
Sure why not....
String Dob=txtDOB.getText().trim();
//get the date from the text box....trim is to remove any spaces if added
java.util.Date CurrentDate=new java.util.Date();
//declaring a variable which will store the current date
DateFormat FormattedDate=new SimpleDateFormat("dd/mm/yyyy");
//convert the date time to the format given
String Currentformat=FormattedDate.format(CurrentDate);
//formatting the current date
Dob=Dob.substring(Dob.lastIndexOf("/")+1);
//get the index of the word from '/'
Currentformat=Currentformat.substring(Currentformat.lastIndexOf("/")+1);
//get the index of the word from '/'
String Age=String.valueOf((Integer.parseInt(Currentformat))-(Integer.parseInt(Dob)));
//calculating age with current date and the DOB
txtAge.setText(Age);
//display the age in the Age text box
Another simple method but with static varibles
Calendar cal = new GregorianCalendar(1988, 2, 6);
//Entering the data of birth
Calendar now = new GregorianCalendar();
//stores current dates value
int res = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
//res will contain the caluclation for difference in years
if ((cal.get(Calendar.MONTH) > now.get(Calendar.MONTH)) || (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH) && cal.get(Calendar.DAY_OF_MONTH) > now.get(Calendar.DAY_OF_MONTH))) {
// if DOB's month is greater than current date month - means bday has not yet come so subtract res
// or ( if the month is equal in both cases then consider the dates of the month... - if bday date is more than also subtract
res--;
}
System.out.println(res);
Ur welcome....
Do visit again in case of any issues or for helping others....
Just a guess...
ur select query does not have single inverted comma...
sql = "Select * from SRuser where Uname = '" & name & "'"
The below code will help u to change the file extension...
Dim myFiles As String()
myFiles = IO.Directory.GetFiles("D:\", "*.txt")
Dim newFilePath As String
For Each filepath As String In myFiles
newFilePath = filepath.Replace(".txt", ".html")
System.IO.File.Move(filepath, newFilePath)
Next
Instead of ClearTextBox(Me)
write the form name in which u want to clear the text boxes
like
ClearTextBox(Form1)
Post ur code so that we can find out where u r going wrong....
May be the below calculation will help u to convert the date to age
String Dob=txtDOB.getText().trim();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, new Locale("en", "AU"));
java.util.Date CurrentDate=new java.util.Date();
DateFormat FormattedDate=new SimpleDateFormat("dd/mm/yyyy");
String Currentformat=FormattedDate.format(CurrentDate);
Dob=Dob.substring(Dob.lastIndexOf("/")+1);
Currentformat=Currentformat.substring(Currentformat.lastIndexOf("/")+1);
String Age=String.valueOf((Integer.parseInt(Currentformat))-(Integer.parseInt(Dob)));
txtAge.setText(Age);
What is ur program actually doing??? what is present in the csv file??
The birthday calculation part u need it for some particular day or 15 days onwards.....
Find the below query that will show the birthdays from current day to coming 15 days
select ID, FName, MobNo, Email, BirthDate
FROM Tablename
where
Day(BirthDate) between day(GETDATE()) and day(GETDATE()+15) and
month(BirthDate) between month(GETDATE()) and month(GETDATE()+15)
Hope it helps u....
Hello....Even I tried the code as it worked absolutely fine....both the newline and the paste part is working for me....
I tried it is Microsoft visual studio 2010 professional version
In ur module along with the control names u need to mention the form names with it...
Form1.dg1.Datasource = dt
.... 'somthing like this....else the module wont understand its is referring to which object...
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New Net.NetworkCredential("abc.def@gmail.com", "abc123def")
SmtpServer.Port = 25
SmtpServer.Host = "mail.google.com"
mail = New MailMessage()
mail.From = New MailAddress("abc.def@gmail.com")
mail.To.Add("abc.ljk@gmail.com")
mail.Subject = "Testing"
mail.Body = subject
SmtpServer.Send(mail)
MsgBox("mail sent sucessfully")
Ur connections are correct...try putting ur credentials at first...the above code works for me.....
Yes u can move ur code in some other module and then directly call the function or so....
like database connections could be in different modules....
the user inputs like u need a text or a number can be in different modules....
creating modules is very good step as if the code is reusable no need to enter the complete code....one u create a module just calling the function will be fine....
its not like its line..... as soon as he reached the end of the line then it wraps.....
However wrapping occurs (ie) when I finish the like till the end
Assuming it to be a crystal report.....for paramaters....
u have an option as Parameter Fields in ur Field Explorer WIndow....
Right click on the parameter Field -> New -> a window will be opened -> Enter the parameter name and the type....and nothing.....->Click OK ->A parameter will get created....
In ur Crystal reports menu -> Reports -> Selection Formula -> Record
Expand the Report Fields....
According to ur condition give the parameter to ur dept id....
where ABC is ur table name
DeptID is ur column name
?deptid is ur parameter....
{ABC.DeptID} = {?deptid}
Then run the report for validation by clicking on main report preview tab....
u will get a window asking for deptid...enter the dept id and check....
Hope this is what u need....
Hey thanks...it worked for me now......
Hello,
My avatar pic is not getting updated....I changed my profile pic from a kitten to a design and even log off from Daniweb still its the same old avatar....
Do visit again in case of any queries or to help others.... :)
First let me clear myself with few things....
->which database are u using
->how many columns would u have in your database
->how many columns would u have in ur csv file...
->if the column numbers are different....then from where is the other data getting populated or which column will be deducted....
waqasaslammmeo - may be u are correct...but as I tried in my case...the panel did not change its size.....
ok...I tried with group box also....
just see if I am going write...
->Created one form
->Added a group box and docked it to left
->added one panel and docked it to right
->in group boxes I added 4 buttons, one check box and one combo box....
->in panel I added 6 labels, 2 text boxes and 2 buttons...
Run the code
the form opens in its window state which I had kept as normal...later I maximized the form by clicking on the maximize button at the forms extreme top right position....
the group box expanded its size and also the panel but the controls inside it were at the same position where I had placed them....
please do tell me if I am going wrong.....
Actually My controls were not getting adjust if my form changes it size....and also I wanted my form to be according to the size of users screen
I set my form windows state to maximum so that it will be maximized for all users in their system
the controls will adjust as the form resizes .....the controls which are to the left will stay to the extreme left...
In my case...
In my form I used 4 panels...
panel1 - dock top
panel2 - dock left
panel3 - dock middle
panel4 - dock right
this when I will resize the form the panel stays at their positions...so we can include the controls in their panel and check...
Hope what Mitja has explained is more clear to u...
it will adjust....as the form resizes the control which are to the left will stay to the extreme left...
In my case...
In my form I user 4 panel...
panel1-dock top
panel2 -dock left
panel3-dock middle
panel4-dock right
this when I will resize the form the panel stays at their positions...so we can include the controls in their panel and check...
I got the answer....
For me the dock property is working perfectly fine....for my controls.....
Ohh gr8....Your most welcome....
Please do visit again in case of queries or helping others.....
Dock method will be the best I think...In flowlayout panel the controls will also move or change their position...
In Dock method...take the panel and set the property to whatever u what....