Jump to content
Xtreme .Net Talk

DonnaF

Avatar/Signature
  • Posts

    31
  • Joined

  • Last visited

Everything posted by DonnaF

  1. Using Linklabels in a Group Box I have an home inventory system. When a person clicks on a "room", I want to be able to display a list of items in that room. Then I want them to be able to click on one of the items, and have detail about that item displayed. What I was thinking of doing was creating a group box, that had an array of link labels in there (I don't how many link labels until a person selects a room). Then a person can click on the link label, have the color changed to show it was visited, and send them to a detail screen. Does anyone know how I can create a group box with an array of link labels? Any helpful hints on how to do this would greatly be appreciated, since I'm not sure how to do this. If anyone has any better ideas on how to approach this, please let me know. Thanks, Donna
  2. I have an application where I am asking the user to enter a signon and password. Then the customer file is read to see if they are valid. I do not need to retrieve any of the data - just verify that the record is on the database table. A couple of questions - How did I determine if the no records were found, after doing the select (see the code below)? Do I need to fill a dataset, and compare the fields (signon and password) to what was passed to the select statement? How do I access the dataset fields to do the compare? The only experience I have is with datasets is filling datagrids. DataAdapter1.SelectCommand.CommandText = _ "SELECT CustomerID, UserPassword FROM Customers " & _ "WHERE CustomerID = 'mcustID' & UserPassword = 'mPassword'" Try DataAdapter1.SelectCommand.ExecuteNonQuery() Catch exceptionparameter As Exception MessageBox.Show(exceptionparameter.Message) End Try I'm never hitting the Catch statement, no matter if the signon/password is valid or not. Thanks, Donna
  3. Does anyone know if password is a VB reserved word? When I looked at the Windows generated code for the Insert Command, I noticed it had password bracketed like there was something special about it. Me.OleDbInsertCommand1.CommandText = "INSERT INTO Customers(Address, City, CustomerID, FirstName, LastName, [Password]," & _ " State, Zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" Password is what I called the field in the database, but maybe I should have called it something else.
  4. I have this code, that does the catch on the error. When the message box pops up, it says: Syntax Error in Insert/Into Statement. That's all it says. Try DataAdapter1.InsertCommand.ExecuteNonQuery() frmNew.lblMessage.Text = "Customer Number " & _ strCustID & " Registered Successfully" Catch exceptionparameter As Exception MessageBox.Show(exceptionparameter.Message) End Try
  5. I'm getting a syntax error on an Insert statement, but I don't see anything wrong with it. It has the correct database names, and they are in the correct order. All of the fields are defined as text on the database. Does anyone see anything wrong with this? Thanks, Donna DataAdapter1.InsertCommand.CommandText = _ "INSERT INTO Customers(CustomerID, FirstName, " & _ "LastName, Address, City, State, Zip, " & _ "Password) " & _ "VALUES ('" & strCustID & "' , " & _ "'" & mFirstName & "' , " & _ "'" & mLastName & "' , " & _ "'" & mAddress & "' , " & _ "'" & mCity & "' , " & _ "'" & mState & "' , " & _ "'" & mZip & "' , " & _ "'" & mPassword & "')"
  6. When I dragged the data adapter, and dataset onto the form, it generated the following in the Windows Form Designer generated code: Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter Friend WithEvents DataSet1 As System.Data.DataSet <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() In order to declare the dataset and data adapter as public, do I need to change Friend WithEvents to Public WithEvents? I'm not familiar with how databases and multiple forms work, so I need some help understanding this. Also, you said I needed to open the other forms from form1, in order to access the database. What would happen if I opened a form3 from form2, and wanted to access the database? Thanks for your help, Donna
  7. I have a database with multiple tables. I want to be able to update different tables on different forms (using VB.Net). Do I need to set up an connection, data adapter and dataset for each form? I would guess that if I'm accessing different tables, that I would at least need to set up different dataset on each form. What about the connection and data adapter? Also, if I access data from one table on a form, can I pass that data to another form? I'm fairly new to processing with databases, so I wasn't sure how this would work. Thanks, Donna
  8. Thank you for your suggestions. It works fine now! I can now write on the panel.
  9. I have a program that is allowing a user to draw on a form, using MouseMove, MouseDown, and MouseUp events. I have added radio buttons, to allow the user to change the color and size of what they are drawing, plus a panel for the drawing area. How do I change my code from drawing on a form, to drawing on a panel? Here's my current code. Thanks, Donna Public Class frmPainter Inherits System.Windows.Forms.Form Dim shouldPaint As Boolean = False Dim newColor As Color = Color.Red Private Sub frmPainter_MouseMove( _ ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseMove If shouldPaint Then Dim graphic As Graphics = CreateGraphics() graphic.FillEllipse _ (New SolidBrush(newColor), e.X, e.Y, 4, 4) End If End Sub Private Sub frmPainter_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseDown shouldPaint = True End Sub Private Sub frmPainter_MouseUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseUp shouldPaint = False End Sub End Class
  10. Mutant, thank you for noticing I didn't assign the value to a variable. I stared at it too long, and didn't see it. Also, I'm new in working with VB.Net. It works fine now. Thanks again for your help, Donna
  11. I've having trouble with the code below. A user will enter a line of text, and the text will then be saved in an array. The first character of the text is saved, and then used in a For Each loop to determine how many times that character appears in the text. When I execute this code, I get blanks in the array instead of the text. Does anyone see anything wrong with my code? Thanks, Donna Sub Main() Dim textArray As Char() = New Char(79) {} Dim savechar As Char Dim intCount As Integer Console.WriteLine("Enter a Line of Text") Console.ReadLine().ToCharArray() savechar = textArray(0) Console.WriteLine(textArray) For Each savechar In textArray intCount += 1 Next Console.WriteLine(savechar & " occurs " & intCount & " times.") End Sub
  12. I am creating a listbox from an array. The user wants to be able to key a number in a textbox to designate which item to delete from the listbox and from the array. I can recreate the listbox, deleting the necessary item. For the array, however, I want to delete the item, and bump up the index for the remaining items in the array behind it. Each time the button is clicked, the array should be decreased by the number entered in the textbox. Each time the array will get smaller and smaller. Does anyone have any suggestions on how to easily do this. I know I can use REDIM, but do I need to write a temporary array, delete the items, and then write it back to the original array, using the REDIM? Thanks, Donna
  13. I found the latest problem! In the SET Statement, it says Task_Description, which is the correct field name. However, in the WHERE statement, it says Task_Desc. When I corrected Task_Desc to Task_Description, the Update worked! Thanks again everyone for all your helpful suggestions. Donna
  14. Thanks everyone for your suggestions. I tried the latest suggestion from zy_abc, and it now seems to be getting around the problem with the date. Now, I'm getting the error "Parameter Task_Desc has no default value". It doesn't like something in the syntax for the Task_Desc field. Does anyone have any ideas on what's wrong with my syntax? Thanks, Donna DataAdapter.UpdateCommand.CommandText = _ "UPDATE TasksTable SET Task_Date=" & _ "'" & SaveDate & "'," & _ "Task_Description ='" & txtDesc.Text & "'" & _ "WHERE Task_Date=#" + SaveDate + "# AND Task_Desc = '" + SaveDesc + "'" Try DataAdapter.UpdateCommand.ExecuteNonQuery() Catch exceptionparameter As Exception MessageBox.Show(exceptionparameter.Message) 'MessageBox.Show("Bad update") End Try
  15. Public Sub SelectNewDate(ByVal newDate As Date) Dim SaveDate As Date SaveDate = newDate The SaveDate gets assigned everytime this routine is called - which is everytime the user selects a new date to view tasks. I have several routines that pass dates to this routine. I still think I just have a syntax problem with the Updatecommand, but I can't seem to figure it out.
  16. I did the messagebox.show, and I got this message "Parameter SaveDate has no default value". It seems to me that I got this message before, and that it had to do with the syntax of a date field in an Insert Statement. Here's my code: DataAdapter.UpdateCommand.CommandText = _ "UPDATE TasksTable SET Task_Date=" & _ "'" & txtDate.Text & "'," & _ "Task_Description ='" & txtDesc.Text & "'" & _ " WHERE (Task_Date = #SaveDate#) & _" " AND (Task_Desc = SaveDesc); " '"WHERE (Task_Date = SaveDate)" & _ '"AND (Task_Desc = SaveDesc); " Try DataAdapter.UpdateCommand.ExecuteNonQuery() Catch exceptionparameter As Exception MessageBox.Show(exceptionparameter.Message) 'MessageBox.Show("Bad update") End Try I just made another change in my code, and now I'm getting the message "Syntax error in query expression (Task_Date =#SaveDate#) AND (Task_Desc = SaveDesc). Here's the latest code: DataAdapter.UpdateCommand.CommandText = _ "UPDATE TasksTable SET Task_Date=" & _ "'" & txtDate.Text & "'," & _ "Task_Description ='" & txtDesc.Text & "'" & _ "WHERE (Task_Date = #SaveDate#)" & _ "AND (Task_Desc = SaveDesc); " Try DataAdapter.UpdateCommand.ExecuteNonQuery() Catch exceptionparameter As Exception MessageBox.Show(exceptionparameter.Message) 'MessageBox.Show("Bad update") End Try Thanks, Donna
  17. I tried the suggestions made, and I still can't get the update to work. I'm still getting my messagebox display "Bad Update". Does anyone have suggestions on what the syntax should be to use a WHERE with two conditions, using an AND? Thanks, Donna
  18. Jon, I'm getting the Message Box Display saying Bad Update (see my code above). How do you display what the error was on the execute nonquery? I am using an Access database. The SaveDate was stored as a date field, based on a selected record from the database. For a date field, do I need to include a # sign? If so, then do you know what the format should be for my update command text? Thanks, Donna
  19. I'm trying to do an update on the database, after changes are made, but I keep getting errors on my update command statement. I'm sure it's a syntax error on my part, but I can't seem to find it. Can someone take a look at my code, and let me know what I'm doing wrong? All the examples I have only use only field for the WHERE, instead of two like I'm using. Thanks, Donna DataAdapter.UpdateCommand.CommandText = _ "UPDATE TasksTable SET Task_Date=" & _ "'" & txtDate.Text & "'," & _ "Task_Description ='" & txtDesc.Text & "'" & _ "WHERE (Task_Date = SaveDate)" & _ "AND (Task_Desc = SaveDesc); " Try DataAdapter.UpdateCommand.ExecuteNonQuery() Catch exceptionparameter As Exception MessageBox.Show("Bad update") End Try
  20. Thanks everyone, for your responses. I've now got the adding of new records to work, using the INSERT SQL Statement. DataAdapter.InsertCommand.CommandText = _ "INSERT INTO TasksTable(Task_Date, Task_Description)" & _ "VALUES ('" & SaveDate & "'," & _ "'" & txtDesc.Text & "')" Try DataAdapter.InsertCommand.ExecuteNonQuery() Catch exceptionparameter As Exception End Try DataSet1.Clear() DataAdapter.Fill(DataSet1, "Tasks") dgdTasks.SetDataBinding(DataSet1, "Tasks") However, I'm not too clear on how to do an update, when a user clicks on an item in the datagrid, and changes it. Also, the key to the record is an autonumber field. How do I get to the current cell info that was changed, update the grid, and also update the record in the database? Any help would really be appreciated. Thanks, Donna
  21. I have a database for tasks. Based on the date selected, I retrieve all the related tasks for that date, and then bind the data to a datagrid. This works fine - the appropriate records are displayed for the selected date. However, I'm very new at using datagrids, so I'm not sure how to add new records, update records, or delete records on the database and reflect the changes on the datagrid. Can anyone help me with how to do this? Here's how I'm binding the data to the datagrid: DataAdapter.SelectCommand.CommandText = _ "SELECT Task_Date, Task_Description FROM TasksTable2 " & _ "WHERE Task_Date = #" & newDate & "#" DataSet1.Clear() DataAdapter.Fill(DataSet1, "Tasks") dgdTasks.SetDataBinding(DataSet1, "Tasks") Thanks, Donna
  22. Jon, I tried your suggestion: datagrid1.update() SqlDataAdapter1.update(DataSet11) but it didn't work. It didn't save the changes made in the datagrid. I made a change in one of the records in the datagrid, and then clicked on an Update Button to execute the code you suggested, but when I displayed the datagrid again, it had the original values. I did use the dataAdapter configuration wizard, so shouldn't your suggested code work? Is there something else I should be doing to get the changed record to update the database? I apologize for being so dense about this, but I've only been writing VB Net code for a couple of months, and I still have alot to learn. Thanks for your help that you have given me so far. Donna
  23. I still need help on this. When I'm displaying the data from the access database in the datagrid on the form, I want to be able to click on the record I want to change, make the changes right on the datagrid, and then update the database and the datagrid(by clicking on a command button). How can I identify which record I'm currently physically on in the datagrid? I would need to know that, so I can retrieve the record from the database to update it. For adding new records, I was going to use a textbox for the user to enter data, and do an insert on the database. Is there a way, instead, where they can just key it on the next line on the datagrid? If so, then again, how do I get to that data on the datagrid, so that I can do an insert on the data base. Any help you can give me would really be appreciated. Thanks, Donna
  24. I have an Access Database that is used to keep track of tasks for each day. On a form, I display the calendar and the tasks for that day in a datagrid. Since I'm pretty new to VB Net, I would like to find out if it is possible to add new tasks, change existing tasks, or delete existing tasks using just the datagrid. It looks like I can type in the datagrid, to add a new task. It also looks like I can change existing tasks information, but I don't know how to identify the changes so I can update the database. For adds - how can I identify what line on the datagrid has been added, so I can do an insert on the database? For updates or deletes, how can I identify which line on the datagrid I have updated or marked to be deleted? Thanks, Donna
  25. I tried your first suggestion, and it worked the first time. Thanks for your help!
×
×
  • Create New...