Jump to content
Xtreme .Net Talk

mza1979m

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by mza1979m

  1. Well, when I use the code I displayed above, I get the following error: Operator '=' is not defined for types 'System.Drawing.Color' and 'System.Drawing.Color'. When I use just 'Red' instead of 'System.Drawing.Color.Red', it says that the name 'Red' is not declared.
  2. In VB.NET, what is the syntax for checking the forecolor of a certain control? For instance, I want to check if the forecolor of my GroupBox control is Red, and if so, perform a certain action. I tried the following, but no luck: If grpTextAttributes.ForeColor = System.Drawing.Color.Red Then ' Block of code here End If
  3. I have a VB.NET program that connects to an external database (MS Access). In this database are 2 tables: "Business" and "Personal". In each table there are numerous fields. Now, programatically, how do I perform a search for a specific record using a specific field? For instance, I want to search for the first record with the value of "Joe" in the "fldFirstName" field. I'd also like to find all subsequent matches. How is that done in VB.NET? In other words, I'd like to translate the following line of VB6 code to VB.NET code: datNavigate.Recordset.FindFirst("fldFirstName = " & "'" & "Joe" & "'")
  4. Yes, I guess I should have put how I'm currently updating the database. Here goes... I use the following to update the database: (I'm sorry, I don't know how to make the code in this message properly formatted/colour coded). Public Sub UpdateDataSet() 'Create a new dataset to hold the changes that have been made to the main dataset. Dim objDataSetChanges As Electronizer.DSElectronizer = New Electronizer.DSElectronizer() 'Stop any current edits. Me.BindingContext(objDSElectronizer, "Personal").EndCurrentEdit() 'Get the changes that have been made to the main dataset. objDataSetChanges = CType(objDSElectronizer.GetChanges, Electronizer.DSElectronizer) 'Check to see if any changes have been made. If (Not (objDataSetChanges) Is Nothing) Then Try 'There are changes that need to be made, so attempt to update the datasource by 'Calling the update method and passing the dataset and any parameters. Me.UpdateDataSource(objDataSetChanges) objDSElectronizer.Merge(objDataSetChanges) objDSElectronizer.AcceptChanges() Catch eUpdate As System.Exception 'Add your error handling code here. Throw eUpdate End Try 'Code to check the returned dataset for any errors that may have been pushed into the row object's error. End If End Sub ----------------------------------- 'The following is used to load the data from the source: ----------------------------------- Public Sub LoadDataSet() 'Create a new dataset to hold the records returned from the call to FillDataSet. 'A temporary dataset is used because filling the existing dataset would 'require the databindings to be rebound. Dim objDataSetTemp As Electronizer.DSElectronizer objDataSetTemp = New Electronizer.DSElectronizer() Try 'Attempt to fill the temporary dataset. Me.FillDataSet(objDataSetTemp) Catch eFillDataSet As System.Exception 'Add your error handling code here. Throw eFillDataSet End Try Try 'Empty the old records from the dataset. objDSElectronizer.Clear() 'Merge the records into the main dataset. objDSElectronizer.Merge(objDataSetTemp) Catch eLoadMerge As System.Exception 'Add your error handling code here. Throw eLoadMerge End Try End Sub ----------------------------------- '...And I'll also include the following subroutines just in case: ----------------------------------- Public Sub UpdateDataSource(ByVal ChangedRows As Electronizer.DSElectronizer) Try 'The data source only needs to be updated if there are changes pending. If (Not (ChangedRows) Is Nothing) Then 'Open the connection. Me.OleDbConnection1.Open() 'Attempt to update the data source. OleDbDataAdapter1.Update(ChangedRows) OleDbDataAdapter2.Update(ChangedRows) End If Catch updateException As System.Exception 'Add your error handling code here. Throw updateException Finally 'Close the connection whether or not the exception was thrown. Me.OleDbConnection1.Close() End Try End Sub ----------------------------------- ----------------------------------- Public Sub FillDataSet(ByVal dataSet As Electronizer.DSElectronizer) 'Turn off constraint checking before the dataset is filled. 'This allows the adapters to fill the dataset without concern 'for dependencies between the tables. dataSet.EnforceConstraints = False Try 'Open the connection. Me.OleDbConnection1.Open() 'Attempt to fill the dataset through the OleDbDataAdapter1. Me.OleDbDataAdapter1.Fill(dataSet) Me.OleDbDataAdapter2.Fill(dataSet) Catch fillException As System.Exception 'Add your error handling code here. Throw fillException Finally 'Turn constraint checking back on. dataSet.EnforceConstraints = True 'Close the connection whether or not the exception was thrown. Me.OleDbConnection1.Close() End Try End Sub To load the data from the database into the text boxes, I use the following code: Me.LoadDataSet()
  5. I have a program that allows me to connect to an Access database (.mdb). I have no problems creating or removing records from within my program then updating them to the data source. My problem is how to modify existing records. It always gives me the following error message: Update requires a valid UpdateCommand when passed DataRow collection with modified rows In VB 6.0, I would use the statement datPersonal.Recordset.Edit (Where 'datPersonal' is the name of my Data Control, which is no longer supported in VB.NET), then datPersonal.Recordset.Update. So what code must I use to suit my purpose? Any help would be appreciated. PS. I hate Microsoft.
  6. That's what I have been using all along, but then you made me realize that my error was elsewhere. It was a logic error. Thanks :)
  7. If I have two pages in my TabControl, how do I bring one to the front programatically, during run time? The name of my control is "TabControl".
  8. Thank you :) That worked perfectly. Thanks a lot.
  9. I have 2 Data Forms in my project (used to access tables in an external database). My question is, how do I show and hide these forms? Obviously, "DataForm1.Show" won't work. Apparently that's been upgraded as well. "DataForm1.DefInstance.Show" doesn't work either. So what is the syntax to show and hide a DataForm?
  10. I've got the following piece of test code in my program... -------------------------------- Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click Dim oConn As SqlClient.SqlConnection ' Dim strConn As String Try ' Create the Connection object oConn = New SqlClient.SqlConnection() Dim strConn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\organizer.mdb") ' Set the Connection String oConn.ConnectionString = strConn ' Open the Connection oConn.Open() MessageBox.Show("Connection Open", "btnConnect_Click()") ' Close the Connection oConn.Close() Catch oExcept As Exception MessageBox.Show(oExcept.Message, "btnConnect_Click()") End Try End Sub -------------------------------- ...yet I get the following error message: Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'String'. Any ideas? I really appreciate you helping me out.
  11. Ok, I'm attempting your idea stustarz, using the code located in the link you provided. However, I've arrived at a little stumbleblock... According to the following instructions... --------------------------- The connection string shown below is an example of how you would connect to a Microsoft Access 2000 database using the OleDbConnection object in System.Data.OleDb. Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Northwind.mdb --------------------------- However, since I'm new to data connections in VB.NET, I have no clue how to use this line in the code. Clearly, this exact line is not VB code, but how do I implement it in my program? Thank you.
  12. Thanks, stustarz. I was able to create a datasource to a specific .mdb file created in MS Access XP (Not programatically during Run Time, but rather during design time). So now I see that database under "Data Connections" in the left pane. I should now be able to bind a TextBox control to a specific field in the database (database file = organizer.mdb ... field name = fldLastName). However, when I expand the "DataBindings" property, then attempt to change the sub property "Text", the only option I have is "(None)", whereas it should display all the fields in my database, according to Microsoft's VB.NET help files.
  13. I have a project that was originally created in VB 6.0. In it, I had a data control and many text boxes that were bound to fields in an external database created in Microsoft Access. Now I've recently converted this project to VB.NET format, and data controls are no longer supported. Alternately, the first step is to create a data source, to which the text boxes will be bound (an .mdb file -- organizer.mdb). My question is, how do I go about creating a data source? The closest I've gotten is by clicking " Tools > Connect to Database... " but I don't know where to go from there or even if that's the correct step. I would really appreciate the help, as I must present this project between the 19th and 24th.
×
×
  • Create New...