|
Create a function into your class and return a boolean true when OK or false when not
|
|
|
|
|
I personally would write, read and update the worker details from the worker class and not use a seperate class. Don't know what it was like in VB6 but writing to and reading from a database in .NET doesn't involve very many lines of code so I'm not sure whether you would be gaining much by using a seperate class for database manipulation.
Also, you mention that your SQL class creates connection strings. Your connection strings should be stored in app.config. If your are using Visual Studio this can easily be done through the settings tab of project properties. And then accessed by My.Settings.ConnectionString .
Hope this helps
|
|
|
|
|
Good idea!If i understood Correctly you advise me to 'join' both classes in a maner of speaking. But the problem is i will have more items to work with like the formation they made and that stuff,thats why i thought in making a classe that manipulates sql data otherwise i will have to repeat processes in other classes for instance:
Worker -Properties
-Actions(Add Worker,Update Worker,Delete Worker)
Formation(studies wtv you wanna call it)
-Properties(name,hours,cost)
-Actions(create new,update,delete)
Formation_Workers(assign_to formation,remove from formation)
As you can see i'll have mutiple places to add remove and update data,so i thought having a general sql class would make sense.
|
|
|
|
|
Sure, in an ideal world it would be great not to have to repeat any code whatsoever, but in my (limited) experience, it isn't always possible or practical. I'm sure it would be possible to achieve what you are attempting but for the amount of code you will be saving, it may be more trouble than its worth. Maybe a more experienced developer can other their opinion on this?
Just as an example, here is a snippet of code I use in each class to insert records into a database, as you can see, there isn't really much to it.
Using cnnSQL As New SQL.SqlConnection(My.Settings.ConnectionString)
cnnSQL.Open()
Using cmdSQL As New SQL.SqlCommand(<<stored procedure name>>, cnnSQL)
cmdSQL.CommandType = CommandType.StoredProcedure
With cmdSQL.Parameters
'add parameters here
End With
cmdSQL.ExecuteNonQuery()
End Using
End Using
|
|
|
|
|
I see what you mean.
From what i'm learning by myself and the conclusion that i get to is that one of the advantages of oop is to reutilize the code so you can write less...maybe i'm just taking that to the extreme
|
|
|
|
|
Hi,
I'm using multiple usercontrol, I'm trying to display the usercontrol2
but usercontrol1 is not getting replaced with usercontrol2.
please help me to solve this problem.
|
|
|
|
|
You can't replace a control, but you can create a new one and remove/hide the old. So in your code, create a new usercontorl2, add it to forms controls, place it in the right position and remove the usercontrol1 from forms controls.
If you're using other containers inside the form (for example tabpage), place the control to the right containers controls collection.
|
|
|
|
|
I have added one combobox column to datagrid view in my windows application.
In Combobox items added is 1,2,3,4,5
even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5
I want atleast one item must be displayed there in combo box by default.
i.e There must be one selected item.
|
|
|
|
|
Set SelectedIndex to other than -1 when you create the column.
Is the column bound?
|
|
|
|
|
first of all thanks for answer darkelv.
For datagridview combobox column there is no selected
index property.
yes it is bound.
I has set displaymember,Valuemember property according to i need it.
|
|
|
|
|
Maybe check if the binding is bound to the correct item/property.
Here's a sample of my code that is bound to an array of enum
Edit: Are you using comboBoxColumn.Items.Add() instead of setting DataSource?
public static AtomDataGridViewComboBoxColumn StatusGridViewColumn(Atom.Interface.ILocale locale)
{
AtomDataGridViewComboBoxColumn status = new AtomDataGridViewComboBoxColumn();
status.DataPropertyName = "Status";
status.HeaderText = LocalText.GetText(locale, LocalID.Create("ChequePrint.Master.Cheque_Status"), "Status");
status.Name = "Status";
status.SortMode = DataGridViewColumnSortMode.Automatic;
status.ReadOnly = false;
status.Width = 90;
status.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
status.DefaultCellStyle.Format = "";
#region .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
ArrayList a = new ArrayList();
a.Add(StatusTypes.Outstanding);
a.Add(StatusTypes.Issued);
a.Add(StatusTypes.Cleared);
a.Add(StatusTypes.Void);
Array enums = a.ToArray(typeof(StatusTypes));
status.DataSource = enums;
#endregion .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
return status;
}
|
|
|
|
|
DataGridViewComboBoxColumn DataGridViewComboBoxCell doesn't have selectedindex or selectedvalue, so you must use Value property instead.
modified on Friday, January 23, 2009 5:05 AM
|
|
|
|
|
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
modified on Friday, January 23, 2009 6:11 AM
|
|
|
|
|
My bad, I didn't mean the column but the cell. DataGridViewComboBoxCell has the value property and it doesn't have selectedindex or selectedvalue.
|
|
|
|
|
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
|
|
|
|
|
I don't quite understand your question. The DataGridViewComboBoxColumn represents the column itself while the cells is one cell in that column on a specified row.
I think there's a very good example here: DataGridViewComboBoxColumn Class[^]
|
|
|
|
|
Can you please try this :
Dim rowCounter as Integer = 0
With CType(Grid.Rows(rowCounter).Cells(0), DataGridViewComboBoxCell)
.Items.Add("1")
.Items.Add("2")
.Items.Add("3")
.Items.Add("4")
.Value = .Items.Item(ind)
End With
Hope this will answer your query
|
|
|
|
|
Hi All,
Kindly suggest me how i use same database file from different Computers. i am using mssql express 2005 with vb.net.
thanks
rmshah
Developer
|
|
|
|
|
Please try these steps :
1. Put the database file (*.mdf) in shared location, and give Full Control to users
Who will use connection e.g. ASPNET user or any machine user in case of windows application.
2. Then use following connection string :
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=<unc-path-to-database-file>;Integrated Security=True;Connect Timeout=30;User Instance=True");
3. Although this may not recommended solution, but It works.
dnpro
"Very bad programmer"
|
|
|
|
|
|
Hello all,
Can any body helps me to find a code for getting files from subfolders or files inside that subfolder.
i know code to get files from folders and subfolders. But if many folders are there, my code fails i.e. folder/subfolder/subfolder/...
i am not sure how many subfolders are there inside a folder
i need the code for getting file from folder/subfolder/subfolder/subfolder..
i am using these code for getting files inside subfolder
For Each fld In path.SubFolders
For Each fil In fso.GetFolder(fld.path).Files
If Right(fil, 3) = "txt" Then
fileNameArray1(fileCounts) = fil
fileCounts = fileCounts+1
End If
Next
Next
please try give the code for getting files inside folder/subfolder/subfolder/subfolder/..
Thanks and regards
Jishith
|
|
|
|
|
You need a recursive function. This[^] KB article show how to do it in C#. Same can be ported to VB.NET.
|
|
|
|
|
The article mentioned in previous reply is perfect call for this situation.
But, Now .NET supports recursive search by using simple code snippet. Have a look in following code snippet :
Dim myFiles() As String = Directory.GetFiles("C:\Temp", "*.*", SearchOption.AllDirectories)
If myFiles.Length > 0 Then
'Do process list of files retrieved
End If
dnpro
"Very bad programmer"
|
|
|
|
|
|
moonshaddow wrote: Error: Illegal characters in path.
Looks like some bad data. What My.Resources.mages returns?
|
|
|
|