Just a question...Why are you declaring two connections?
Reverend Jim commented: OK. Not so messy after all. +9
M.Waqas Aslam commented: ;) may be yes +5
adam_k commented: yep +9
Just a question...Why are you declaring two connections?
I think your problem may lie with the rowsTotal -1.
Are you think of the rows as an array?
If you are a student, then you shouldn't just request a project.
You should show a little effor before we can offer to help you.
Now, if you have ideas or code, post them.
We can't do your homework for you.
For such a small deployment, I suggest using Click Once Deployment.
You can deploy your application by publishing the application.
The settings can be set in options for the desktop icon ect..
You will simply need to naviagte to the publish directory and then run the setup.exe in that directory.
---Table Name: Orders--
-Or_ID- -Or_date- -Or_Amnt-
1 11/11/2011 204.45
There is a free extention for Visual Studio that does this. Open visual studio, and go to the extention manager. Go to online templates and look for Google GEO Pack 2010
Create an orders table to store the meta data of the order, and then store the order id in the customer table.
You can force your delete/refresh by making the delete form modal and creating a sub procedure that will refresh the data in the parent form.
Form2.TextBox6.Text = Form2.TextBox6.Text & Form1.TextBox6.Text
Have you tried using the Cell.Leave event?
Like this:
Private Sub DataGridView1_CellLeave(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
'Your Code here
End Sub
OR you can try:
Private Sub DataGridView1_CellValueChanged(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
'Your Code here
End Sub
But I have never used ValueChanged and you may run into problems with an infinitie loop.
Cell Value Change > Calculate Total > Post Total > Cell Value Change.....
Ok,try this.
This should work fine with SQL Server 2008
'Be sure to import System.Data.OleDB
Dim constr As String = "Provider=SQLOLEDB;Server=BRMS-SERVER;Database=CavsuDB;Integrated Security=SSPI"
Dim sstr As String = "SELECT username,password,category FROM tbl_user WHERE username='" & txtUser.Text & " AND password='" & txtPass.Text & "'"
Dim con As New OleDbConnection(constr)
Dim cmd As New OleDbCommand(sstr, con)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Try
con.Open()
'Set the string to the data adapter
da.SelectCommand = cmd
da.Fill(ds, "GetData")
dt = ds.Tables("GetData")
If dt IsNot Nothing Then
If dt.Rows.Count > 0 Then
Main.Show()
Me.Hide()
If chkAdmin.Checked = True Then
cmd.CommandText = "SELECT username,password FROM tbl_user WHERE categor='Admin'"
da.SelectCommand = cmd
da.Fill(ds, ("adminUsers"))
dt.Clear()
dt = ds.Tables("adminUsers")
If dt IsNot Nothing Then
If dt.Rows.Count > 0 Then
Main.AddUserToolStripMenuItem.Enabled = True
Main.DocumentToolStripMenuItem.Enabled = True
Main.SubjectsToolStripMenuItem.Enabled = True
Main.FacultyToolStripMenuItem.Enabled = True
Main.DepartmentToolStripMenuItem.Enabled = True
Else
MsgBox("There was a problem retrieving the admin users.", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("Admin table is empty.", MsgBoxStyle.OkOnly)
End If
ElseIf chkAdmin.Checked = False Then
cmd.CommandText = "SELECT username,password FROM tbl_user WHERE category='user'"
da.SelectCommand = cmd
da.Fill(ds, ("Users"))
dt.Clear()
dt = ds.Tables("Users")
If dt IsNot Nothing Then
If dt.Rows.Count > 0 Then
Main.AddUserToolStripMenuItem.Enabled = False
Main.DocumentToolStripMenuItem.Enabled = True
Main.SubjectsToolStripMenuItem.Enabled = False
Main.FacultyToolStripMenuItem.Enabled = False
Main.DepartmentToolStripMenuItem.Enabled = False
Else
MsgBox("There was a problem retrieving the users.", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("User table is empty.", MsgBoxStyle.OkOnly)
End If
End If
Else
MsgBox("**USER NOT FOUND**", MsgBoxStyle.OkOnly)
End If
Else
MsgBox("Data table is empty.", MsgBoxStyle.OkOnly)
End If …
You can add a color dialog to your project, and pull the color from that.
A color dialog holds a custom color picker.
As for the scanning, if you are looping through the whole width/height of the screen it will take a long time. The only other way to fix other than the stepping will be to reduce your resolution.
Place the code in a try catch block
Try
'Your code here
Catch ex As Exception
MsgBox(ex.stacktrace.Tostring)
End Try
This will show the exact line that is throwing the error.
Or, alternately. Test each value before performing the action.
If fontSelection.Text <> "" AND Document.SelectionFont.Size ISNOT Nothing AND Document.SelectionFont.Style ISNOT Nothing Then
End If
You will need to search for the name in the database.
Create a query then execute the query, fillng a table.
After the table has been created, place the values and update the table.
Fire the code off from the payment textbox's Leave event.
That way after you leave the payment text box, the total is calculated.
You could:
'Fist grab the total
try
Dim s As String = "SELECT payment FROM customer WHERE cust_id=" & cusID '< A variable that you asign the value to.
Dim cmd As new OLEDBCommand(sqls,con)'Where con is OLEDBConnection(See URL Below)
'Be sure to open the connection
con.Open()
Dim da As OLEDBDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
da.SelectCommand = cmd
da.Fill(ds,"GetInfo")
dt = ds.Tables("GetInfo")
'Then you will need to pass the value into a variable.
Dim amount As Double = dt.Rows(0).Item(0)
amounr += paymentAmnt 'Amount the customer payed.
'Now you need to update the table.
s = "UPDATE customer SET amount=" & amount & " WHERE cust_id=" & cusID
cmd = New OleDBCommand(sqls,con)
cmd.ExecuteNonQuery
Catch ex As Exception
MsgBox("Exception From:" & ex.Source & vbcrlf & ex.message)
End Try
Here is the URL
You will need a seperate table for the customer.
Something Like
::Table Name: Cust_info::
::Column 1:cust_id::
::Column 2:cust_name::
::Column 3:cust_charges::
::Column 4:cust_payed::
You can get rid of the has rows, and try:
If myData IsNot Nothing Then
Do While myData.Read
'Place your code here.
'Use GetValue instead of .toString
Loop
Else
MsgBox("Empty Reader")
End IF
I have just one question though.
Is a color dialog out of the picture for your program?
If not, it would make your life SO much easier.
Other than that, what is the height of BMP?
Yep, or dispose after using. That might cause an exception though.
The easiest way I know of would be to loop through the file and add the values.
If they were comma delimited and in order, you could just loop until you hit end of file.
Is SQL client required? If not, I can try to rewriting using an OLEDB client, which I am more famillar with. But this will require you to test it due to your database being local.
If the variable creation is in the loop, you are not disposing the bitmap before trying to create another with the same name.
Be sure to close the thread if you have solved your issue.
Thank you.
If the elements are stored in a database or Excel workbook, you can just pass it in with a loop.
Where are you getting your data from? (If you can disclose that information)
You can use a date/time picker and date objects.
For date objects you can try:
'Create a date object.
'You can default the date to a date from the database.
Dim datobj As Date = Now
'For 15 days from the day of execution.
Dim nextPay As Date = Now.AddDays(15)
'You can also pass a date in from the database.
'Value is from a datatable.
Dim datobj As Date = dt.Rows(0).Item(0)
'To check if the day is a weekend, try this:
If datobj = DayOfWeek.Saturday Or datobj = DayOfWeek.Sunday Then
MsgBox("Payment will fall on weekend.", MsgBoxStyle.OkOnly)
End If
If there is an On Click event, please post the code so that I can review it.
Have you checked to make sure you aren't overwritting the picture when the On Click event is fired for the tool strip button?
Have you made sure the the dll import points to the right dll in Windows XP?
Does it do it in only in the environment, or on runtime also?
You will have to redraw the listview. I normally use a chain of sub procedures to:
1) Design (Columns)
-Calls-
2) Get Data (Data Reader)
-Calls-
3) Fill the listview
You can create this in one procedure, but I made it 3 for flexibility.
I hope this helps.
If registry keys are not an absolute must, you can use the application settings to save all of the information.
Example:
'Where savedwidth has been added as a int in the application settings.
Me.Width = My.Settings.SavedWidth
'Then for saving you can...
My.Settings.SavedWidth = Me.Width
My.Settings.Save()
For question number 3, you can place picture boxes with the pictures in them.
Hide all of the picture boxes and when the user checks a certain checkbox, change the picturebox to be shown.
You can do this in vb
If IsDBNull(value) then
'Value is null, place code to handle here.
End if
You will want to create a listview item, and then bind the .text of the listview item to a unique value(primary key) then build the item and add it to the listview.
Example:
dim itmListView as New ListViewItem
'Random value, substitute it with your own.
itmListView.Text = iamunique
'Next add your values
'Example is if myValues was a datatable.
for i = 0 to myValues.rows.count - 1
itmListView.Subitems.Add(myValues.rows(i).Item(0))
next
MyListView.items.add(itmListView)
You can get your data from the data adapter by creating a data set and data table then passing it through.
'da = Data Adapter, ds = Dataset, MyValues = datatable
da.fill (ds,"tablename")
MyValues = ds.SelectTable("tablename")
To safeguard from NULL references, try this.
'Place a try catch block and an extra if for added protection.
Try
If MyValues isnot Nothing Then
'Your code here.
End IF
Catch ex as Exception
MsgBox("Oops!" & vbcrlf & ex.message")
End try
Hope this helps
Sorry, I typed it on the fly.
I forgot about the new Point.
Try this instead.
'For new Y position.
Button1.Location = New Point(Button1.Location.X, Me.Width - 30)
'For new X position
Button1.Location = new Point(Me.hieght - 100, Button1.Location.Y)
First of all Congratulations.
Second of all, is it possible that this is considered a spammer? Just a question.
The ancor and dock methods might not always work.
That's when I resort the the following method:
'You will have to play with this to get everything right.
'This will automaticly move when the user resizes the window too.
Button1.Location.Y = Me.Width - 30
'You can do the same for the X location.
Button1.Location.X = Me.Height - 10
No problem at all friend. I hope you find the solution to your problem.
What you posted is EVERYTHING out of the single vb file? If so, I would check for some rogue characters outside the namespace/end namespace
By copy/pasting into VS and creating my own dummy class of Sales I managed to get it working.
Perhaps something wrong with other code in the same .vb file?
What you could also do is:
'Set the indexes of the controls, then use this code:
'Capture the enter key and go to next control
Where i is the index of the control
Me.Controls(i).Focus()
My mind just threw a StackOverflowException from thinking about this.
A high-level language, simulating a low level language, which is powered by a high level language, that gets converted to a low level language.
If you are working with non database items, you can try parsing each item in the gridview.
Like this:
dt2.rows('index') = dt1.rows('index')
'So, like this
'dt2.row(0) = 0
'dt1.row(1) = 15
dt2.rows(0) = dt.rows(1)
dt2.rows(0) = 15