Best Practice While Working With Dataset?
Jun 25, 2009
What is the best practice while working with dataset amd datatable.Actually I have seen that very few information is online when it comes to working with multiple base table.Suppose there is one master table and a details table. The need of MASTER table is suppose just one column (say ProductName), while the application mainly works with the DETAILS table.My idea, we use JOIN to create a single datatable and work with it. But am surprised how little information is available when it comes to working with Multiple Base Table and the limitation of SQLCOmmandBuilder in such situation.
View 15 Replies
ADVERTISEMENT
Mar 17, 2010
I have some problem with working with tables which were created on previous form. Say we have a form Customers in which Customers are displayed in datagridview.Now to create or add ne customer to this customer table on sql server, another form is opened.In this form user enters all data like customer name, phone number etc. when changes are made to the sql server using a stored procedure this form is closed now I want to show this newly added customer in the datagridview of the previous form.Right now what I am doing is creating data set and command et. and again fetching data for all customers from sql server.
View 2 Replies
Sep 13, 2010
Anyway, I wrote a view with a union query in SQL Server that grabs data from a linked SQL server.
Anytime I try to add this object as a dataset in VB.NET it completely bombs out on me with this ugly error message...
ERROR [42000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] The operation could not be performed because the OLE DB Provider 'SQLOLEDB' was unable to begin a distributed transaction. ERROR [01000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] [OLE/DB provider returned message : new transaction cannot enlist in the specified transaction coordinator] ERROR [01000] [Microsoft] [ODBC SQL Server Driver] [SQL Server] OLE DB Error Trace [OLE/DB Provider 'SQLOLEDB' lTransactionJoin::JoinTransaction returned 0x8004d00a]
I'm completely stumped as to why I can't create a dataset from a view that references a linked SQL server. It's not this specific view either, all views that reference this linked server bomb out.
View 1 Replies
Feb 13, 2012
I have an ErrorProvider on a form with a DataGridView.The Binding Source for the DGV points at a single table in the DataSet (which hooks up to an underlying Access DB).The table has two columns:
1) Autoincrement PK
2) Text field, <=25 chars, unique, can't be Null or empty string
I test for string length (>0 and <=25) in the DataSet.Table.RowChanging event.If it's out of range then I use e.Row.SetColumnError, that passes the error to the ErrorProvider / DGV on the correct row and DataSet.HasErrors returns True. All good, no problems.
I test for uniqueness in the DataSet.Table.ColumnChanging event.If it's not unique I can set the error with either e.Row.SetColumnError or e.Row.RowError; Now it gets complicated since sometime this makes the ErrorProvider / DGV show the error and sometimes not, it depends on whether the DataSet keeps the Unique = True constraint of the underlying DB.
Why would I have the DataSet be False for Unique when the DB is True for same constraint? So that the user interaction with the form has the minimum of dialogue box based interuptions. I am trying to design a system whereby all issues / errors are reported
to the user as they interact with the form in a subtle way, allowing them to keep working but trapping errors before any attempt to Save from the DataSet to the DB.
So, if the DataSet keeps the unique constraint then when you insert the new (duplicate) row the DGV throws its DataError event, a default dialogue appears, behind which the DGV has the ErrorProvider icon on the correct row. However, since the DataError event
causes the problematic change to be rolled back, the new row is removed and the error disappears.
If I change the DataSet requirement to Unique = False, then SetColumnError does not cause an ErrorProvider icon to be shown and DataSet.HasErrors returns False. I can improve upon this slightly by using RowError, this causes DataSet.HasErrors to return True but the ErrorProvider icon still does not show.Further, when using Unique = True on the DataSet, and editing an existing row to be a duplicate of another, the behaviour is the same, DGV.DataError event, roll back of the change but the ErrorProvider icon remains, despite the row no longer being a duplicate and DataSet.HasErrors returns True. The text of the the ErrorProvider tooltip is the one from SetColumnError, not RowError.So, the behaviour of SetColumnError is affected by the state of the DataSet field Unique constraint?
Unique = True
SetColumnError affects the DGV / ErrorProvider and DataSet as expected.
(RowError behaviour unknown)
Unique = False
[code]....
View 3 Replies
Apr 27, 2010
vs2010 vb.net QUESTION1 If i do a select and fill a datatable and want to access that data from another class. How can I do that? QUESTION1 example
[Code]...
View 1 Replies
Aug 20, 2009
Which is a better practice? (I'm coding in .Net if that makes a difference)
IF condition = true THEN
...true action--even if rare...
ELSE
[code].....
View 10 Replies
Jul 1, 2009
I have a SQL 2008 Express database, which have following tables: [code] Now I need SQL query to search for word (i.e. Beyonce Halo Music Video) against these tables.
-For Title exact phrase will get 0.5 points
-For Description exact phrase will get 0.4 points
-For tags exact phrase will get 0.3 points
-For title all words will get 0.2 points
-For description all words will get 0.2 points
-For title one or more words will get 0.1 points
-For description one or more words will get 0.1 points
And I will show these videos on basis of points. What will be the SQL Query for this? A LINQ query will be more better.
View 2 Replies
Feb 4, 2011
I'm writing in VB.net 4.0 and using SQLExpress 2008 R2. In a DataGridView, I would like to display (no edits) data coming from multiple tables in my database.A second Grid (different data, still multiple tables) will need to allow editing and saving of data.I understand creating a View in the database and using that as a source for the DataGridView.I also assume that there are ways to query and create a data source for the Grid totally within my VB program.Would someone explain the consequences and implications of the different approaches?
View 2 Replies
Apr 9, 2009
I am allowing users of the admin panel of my website to upload photos, its a simple process where I check the validity of the image and then save it to a folder, then I also have to record a couple of database records for that image to be able to retrieve it later, my saving function is as follows...The function that uploads and saves the picture in the folder with a name i construct in another function: [code] and the function that creates the database record for that same picture: [code] Now I know that what I am doing is full of best-practices violations, so please point me out to what I should do, keep in mind that the users might delete the pictures later, so I wanna make sure that I can delete the database and file of the picture, and the whole issue of the path.
View 2 Replies
Dec 8, 2010
What is the best practice way of detecting internet connection?
From Windows Vista onwards, a status is set in windows that is displayed in the task bar. However, I cannot call this function/api/whatever, since some of the client pc's are still on xp, and only due for upgrade in 18 months.
so do i use and request something like [url]... to try and see it it works, and on the catch block set the return value to false, or is there another way?
Second part of this question, If no network connection is available, I can use [url]... to dial a connection. Will this use internet explorer's settings, or dial the connection marked as default in DUN?
Public Sub Life(ByVal AnyEvent As Object) Dim myNewLife As New Life Dim Happiness As New Collection Happiness.Add(AnyEvent) myNewLife.Experience(Happiness) End Sub
View 4 Replies
Jan 27, 2011
If I got Dim myRect As Rectangle = New Rectangle(0,0,100,100)Is it necessary or just fine to later do this: myRect = Nothing Or it isn't necessary?IF it is necessary, are there other cases it isn't for my variables?
View 2 Replies
Mar 24, 2011
I am in the processing of migrating from web services to WCF, and rather than trying to make old code work in WCF, I am just going to rebuild the services. As a part of this process, I have not figured out the best design to provide easy to consume services and also support future changes.
[Code]....
View 1 Replies
May 4, 2009
Can anyone point me towards a complete scenario using MSTest,vb.net, with or without mocks,MVP (supervising controller)
View 1 Replies
Mar 27, 2011
I need to share variables across two forms in vb.net. One of them is the main form and the other is a child form.
Create a static/shared variable in one of the forms and access it in the other forms via:
Form1 frm = new Form1(); //creating object of parent to access shared variable
frm.a = "abc"; // passing value
Send an instance of the main form to the child form when creating the child form. The variables can then be accessed via a property function. Create global variables in a module. This seems like the easiest option, but I doubt it is the best option.I also read something about delegates and events, but I don't know how to implement this.
View 4 Replies
Aug 23, 2011
I'm just wondering why using GoTo<label> is so frowned upon?I'm learning VB, and I want to develop good habits as I go. One thing I don't entirely understand, is why everyone avoids GoTo like its the plague (except in error handling...). I feel like GoTo could be useful in some situations.
View 1 Replies
Mar 27, 2012
Just wondering what the recommended practice is for importing namespaces. Are you always better importing the namespace like the fisrt snippet of code, or are you better to type the full namespace inline with your code.
I like both methods; the first is tidier and takes less code, the second can identify exactly where your accessing some logic from which can provide some clarity when looking over the code. Just wondering if there are pros/cons for either or if this is just a personal preference, currently I use a combination but would like to keep consistant.
[Code]...
View 2 Replies
Jan 21, 2010
Below two which is the best practice to compare strings...
If "A".ToLower = "a" Then
'....
End If
If String.Compare("A", "A", True) = 0 Then
'...
End If
View 2 Replies
May 15, 2012
I've got a class that looks like this
[code...]
What is the best way to "clean up after myself" when I am done with this newFS object?
View 3 Replies
Aug 29, 2011
I come from a C# background so I'm not quite up to snuff on my VB just yet.I've run across this practice all over our code base and it is never used for chaining.I am wondering what performance consequences (if any) this might create. [code]
View 2 Replies
Jul 26, 2010
I recall being told by a professor the following is bad practice. But it makes stepping through code a lot less tedious. I'm just solicting comments on pros and cons:
Friend Class MyClass
Private isEmpty As Boolean
Public Property IsEmpty() As Boolean
[code]....
View 3 Replies
Feb 21, 2012
The Adventureworks database is used extensively for tutorials in Visual Basic applications. This has many tables that can be bound to a solution. What I would like to know is, when using such a large database with many tables and using lots of them, is it better to construct your program with a number of projects all under one solution or to put everything into a single project. If you use a number of projects, what is the syntax for accessing each module from a menu strip in your main form? I know how to do this in a single project - all you do is Form(x).show. In Adventureworks, you have a table for Employees that could be put into a single project with a number of forms - one for data entry, one for displaying all of the employees, a filter to a single employee, etc., etc.
If two small projects rely on each other for some reason, again the syntax for linking them could be an issue. Would it be better to combine them into a single project? My reason for asking is that I would feel safer if I created an application on a project by project basis and then brought them all together in one solution. This way they can be tested individually and then linked together where necessary. Making a disastrous mistake in one then only requires a small re-write rather than the headache caused by a total crash of the whole solution. I would like to know which option professional developers take. I am using Visual Studio 2008 Professional and SQL 2005 Express
View 5 Replies
Oct 9, 2009
What are best practices when creating a custom event log for a windows service? I've set my service on a timer so it fires up every day (except weekends) at the same time. For the last 3 days, I've been getting the following error: The source 'DMCS57ExportService' is not registered in log 'DMC S57 Export Log'. (It is registered in log 'DMCS57ExportLog'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property.Based on that error, I know there's something wrong with the code that creates the custom event log (see below)
[Code]...
View 3 Replies
Sep 7, 2011
I took over an ASP.NET application and have found this throughout several classes in the application. The programmers before defined several shared/static variables that act as "complex enums" throughout the application. As a fairly new programmer, it doesn't look like best practice.
Here is an example:
Public Shared SecureCommentsWrite As New Task("Secure Comments Write")
Public Shared SecureCommentsRead As New Task("Secure Comments Read")
Public Shared EditEmergencyContact As New Task("Edit Emergency Contact")
Public Shared DisplayPersonalReferences As New Task("Display Personal References")
Public Shared EditPersonalReferences As New Task("Edit Personal References")
The constructor takes the description, then loads the ID key from the database using a stored procedure (the database is SQL Server.) This seems like a good idea since we deploy this application to multiple databases and want to ensure that we load the ID key that's in that database in case it changes. However, since there are literally hundreds of these in the application, the first load takes a while.
View 4 Replies
Jan 12, 2012
When I want to maintain code readability and keep things neat. I would create temp variables . Below is one of my functions that uses it. Is it a bad practice? I would create temp variables cost more memory ?
Private sub test(byref transac as transaction , byref txntime as string )
Dim cmd as OracleCommand = nothing
Dim Adapter As OracleDataAdapter = nothing
Dim SQLStr As New StringBuilder
[Code] .....
View 9 Replies
Jun 10, 2009
say you have a database that you want to store 100 different recipes in. Out of that 100 recipes 20 have 5 ingredients, 30 have 7 ingredients, 30 have 4 ingredients and 20 have 6 ingredients. So what's the best practice for storing an unknown number of items in a database?
Currently what I am doing in these situations is storing them in a single field in a database separated by a comma. Then when I have to retrieve them I split them by the comma into an array. This doesn't seem right to me but I haven't noticed an impact on speed or efficiency, so what would be the best practice to handle this situation?
View 2 Replies
Nov 20, 2009
Starting to design an application and wondering if its ok to have only one form as the application which could hold up to 15 gridviews separated in tabs etc. with a navbar as navigation on the left. Is this too much or ok? Is it better to have one gridview per form? What is the norm?
View 6 Replies
Nov 21, 2009
I am trying to make a simple resistance calculator for practice. I use text boxes to let the user input the current and voltage, and then a combo box for the units and then a list box to display the results. For some reason no matter which units I select it doesn't convert at all. For example 1/2 will always show up as 0.5 in the list box no matter which units are selected from the combo box. Here is my code.....I know that there is more cases but I only put one to see if it works before I write all of the cases.
Public Class Form1
Dim unitsA As String
Dim unitsV As String
[code]....
View 1 Replies
Mar 19, 2010
To practice loops in console application more
sth like this one:
CODE:
so this is my code that worked but only gave 1 as an answer which is wrong
CODE:
View 12 Replies
Mar 16, 2010
Sorry if this is a bit random, but is it good practice to give all fields of a class a value when the class is instanciated? I'm just wondering if its better practice to have a constuctor that takes no parameters and gives all the fields default values, or whether fields that have values should be assigned and others left alone until required?
View 4 Replies
Mar 31, 2009
Just want to know the best method to load a picture in a picture box dynamically. As part of my development, I was supposed to load 4 pictures from network to 4 picturebox controls.
For which, I found, 2 methods.
1. Picturebox1.Image=new bitmap("C:\test.jpg")
(or)
2. Piturebox1.ImageLocation="C:\test.jpg"
Which one is more suitable interms of performance.
View 9 Replies