lolafuertes 145 Master Poster

A simple way is to Use a log in form to ask for them ( a 2 textbox form and an accept and cancel buttons may be enough)
If the user cancels, then close the application.

You can verify if this is an allowed user by searching it in the database of allowed users.

If the user is allowed, then register the start of the session in a public variable in the main module of your application, to be used across all your forms.

Hope this helps

lolafuertes 145 Master Poster

Do not use the following characters in the file name:
/ (slash)
\ (back slash)
? (question mark)
* (star)
" (quotes)
> (greater than)
< (less than)
| (pipe)
: (colon)
(\0) (null char)
The : (colon) character can appear only once in the full path to define de unit like C: or PRN:
The \ (back slash) character can appear twice at the begning instead of the unit to define a network path. Ie \\MyServer.
Also the \ back slash character is used to name the full directory path like C:\Users

The file name (including the extesion if any) must not finish with a blank or null char.

The $ at the end of a sharing name is used to hide the directory or unit

See this article from Wikipedia to learn about file system and naming conventions.

Hope this helps

lolafuertes 145 Master Poster

Read here for the Access 2010 Runtime, Database Engine Redistributable

Hope this helps

lolafuertes 145 Master Poster

I would suggest to uae

textBox7.Text = oreader.GetString(0)

Hope this heslps

lolafuertes 145 Master Poster

I am using the professional version and has a project of type installer, but I will bet that in VS Express you can create a new project of type ClickOnce Security and Deployment (see here).

Hope this helps

lolafuertes 145 Master Poster

I found that in the returned data there is no PartylistName field. You only return the fields Lname, Fname and MI according to your select clause.

Sorry not to see it before.

dr = cmd.ExecuteReader
if dr.HasRows() then
    While dr.Read()
            cbPres.Items.Add (dr("Lname") & ", " & dr("Fname") & " " & dr("MI").ToString())
    End While
Else
    MsgBox "Nothing to show"
End If

Hope this helps

lolafuertes 145 Master Poster

Please try

dr = cmd.ExecuteReader
if dr.HasRows() then
    While dr.Read()
        If cbPartylist.Text = (dr("PartylistName").ToString())Then
            cbPres.Items.Add (dr("Lname") & ", " & dr("Fname") & " " & dr("MI").ToString())
        End If
    End While
Else
    MsgBox "Nothing to show"
End If

And let us know the result.

Hope this helps

lolafuertes 145 Master Poster

Assuming there is one record to show, the

If objDataReader.Read = 0 Then
         
End If

will read the first record returned; then

While objDataReader.Read

will try to read the second one, but only one exist so the condition is currently false and nothing filled in the listview.

I will suggest the following code

If objDataReader.HasRows() Then
    Try              
        lvwSearch.Items.Clear()
        While objDataReader.Read
            Dim lv As New ListViewItem
            With lv
               .Text = objDataReader.Item("accountNumber")                    
               .SubItems.Add(objDataReader("division"))
               .SubItems.Add(objDataReader("Assignee"))
               .SubItems.Add(objDataReader("phoneUnitModel"))
               .SubItems.Add(objDataReader("handPhoneNumber"))
            End With
            lvwSearch.Items.Add(lv)
        End While
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
    myConnection.Close()
End If

Hope this helps

lolafuertes 145 Master Poster

The dr has rows?

lolafuertes 145 Master Poster

I would suggest 2 points:

1) Change Public Function GenerateCode() As Object to Public Function GenerateCode() As String 2) Change Public Function GetPID() to Public Function GetPID() as String Hope this helps

lolafuertes 145 Master Poster

Please post your table design and code written in order to try to help you

lolafuertes 145 Master Poster

Plase, be so kind to try

dr = cmd.ExecuteReader
While dr.Read()
    If cbPartylist.Text = (dr("PartylistName").ToString())Then
        cbPres.Items.Add dr("Lname") & ", " & dr("Fname") & " " & dr("MI").ToString())
    End If
End While

Hope this helps

Unhnd_Exception commented: Solved +8
lolafuertes 145 Master Poster

On your installer project, on the file system, under application folder add the database.

If if you need the database in a distinct folder, then add it to the file system tab and put the database inside.

Hope this helps

lolafuertes 145 Master Poster

Is really easy to implement.

Assume you want to modify the value of a progress bar, in htis example toolStripProgressBarMain. Direcly assigning the value to the control can result in a cross threading unsafe call. To avoid this

Create a delegate like:

Delegate sub SetProgressDel(percentage as double)

And instantiate it to pint to the right procedure

Public myDelegate = new SetProgressDel(AddressOf setProgress)

Then create a sub that will do the work like:

Public sub SetProgress(percentage as double)
    '
    '   Verify if we are running on the same or distinct thread
    '
    If statusStripMain.InvokeRequired then
        '
        '  We are in a distinct thread so use the invoke instead
        '
        try
            '
            '  Invoke the external thread
            '
            toolStripProgressBarMain.Invoke(myDelegate, new object[] { percentage })
        catch ex as Exception
            msgbox "invoke failed" & ex.Message
            Exit sub
        End try
    Else
        '
        '  We are in the original thread, then
        ' Assign the value
        toolStripProgressBarMain.Value = Ctype(percentage, int)
    End If
End Sub

And in your thread safe call, instead of assign the value to the control, call the procedure.

I translated this from c# and this vb is untested, but that's the way.
Hope this helps

lolafuertes 145 Master Poster

You need to re-dessign all your program. Is not possible to do it with the same code.

If you want, you can zip all your project and uplad it here inorder some one can read it and, if is possible, show you where you need to change the design or your code.

lolafuertes 145 Master Poster

Yes. That is right.
But...

The database you created is the phisical data container.
The Dataset you fill is the logical container for the extracted data of a database.

Each time you do a select from the phisical database to fill a datatable in the dataset, you are creating a partial logical view (even if it contains all the fields from the database). This logical view can have any name, but this will not guarantee that it has the same structure than the database. The structutre of fileds will be those included in the select clause.

The code

Dim ds As Data.DataSet = New Data.DataSet("purchasetable")

erases any previous definition of the datatable "purcharetable" and creates a new definition based on your

"SELECT available_bal,SUM(available_bal) FROM purchasetable WHERE available_bal=0 GROUP BY available_bal"

Please have in mind that the dataset is a virtual database that can be changed on the fly and that does not is the actual phisical database.

So as Mitja and I said before, you need to create a new and distinct logical view (datatable) from the same phisical database to be the datasource to be bound to each combo box: onecombobox - onedatatable, anothercombobox - anotherdatatable.

Hope this helps

lolafuertes 145 Master Poster

No, your error is not related to the pooling.

In your example:

da.Fill(ds, "purchasetable")

is using the following 2 fiels for this table according to your select: available_bal and SUM(available_bal). This will create a table called "purchasetable" with only 2 columns.

Then you try to create a new row from the existing "purchasetable" with a lot of fields not existing in there:
newrow("date") = TextBox1.Text
newrow("amt") = TextBox2.Text
newrow("discount") = TextBox3.Text
'newrow("bill_amt") = TextBox4.Text
newrow("invoice_date") = TextBox5.Text
newrow("invoice_no") = TextBox6.Text

You need to be consistent in the table definitions.

Hope this helps

lolafuertes 145 Master Poster

See here for a keys enumeration.

Hope this helps

lolafuertes 145 Master Poster

A simple way is to declare year and month primary keys in the SQL table definition. When you insert an existing one, the SQL will answer with an exception of duplicate key.

Another way is, before creating the new row, analyze the existing rows in the datatable (using a "for each / next") and if a row containing the month and year exist then show a message and exit the sub. Else, insert the new row.

Hope this helps

lolafuertes 145 Master Poster

@GeekByChoiCe: Thanks for your support. But if compares the contents of the "D:\pmesseng.txt" and "E:\pmesseng.exe" after decoding them as in the example, motsly will not see any difference. :)

lolafuertes 145 Master Poster

For your purpose, line 89 should be

Try
    myData = command.ExecuteReader()
    If Not myData.HasRows Then
       ' Password not found
       'TODO: what you will need when the user and password does not exists in the DB
    Else
        ' Password found
        'TODO: What you will decide when the password is found
    End If
Catch ex as exception
    'TODO: Show the error
Finally
    myData.Close()
End Try
lolafuertes 145 Master Poster

Actually I am lost. Do you need an example of what?

Please be so kind to consider putting all your code here and clarify wich are your expected behaviours, the expected results and the current ones.

Many thanks

lolafuertes 145 Master Poster

Please try:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim myVar As String
    myVar = Strings.StrConv(TextBox1.Text, VbStrConv.ProperCase)
    TextBox1.Text = myVar
End Sub
lolafuertes 145 Master Poster

You can't convert a file being an exe to be a .bat or a .msi

In fact, what you are doing on your code is just renaming a .txt file as .exe

Obviously you can rename a file to whatever you want, but this will not convert it.

lolafuertes 145 Master Poster

IMO to fill the valid text you do not need the line

IncomeCodesBindingSource = CBIC.SelectedValue
lolafuertes 145 Master Poster

Sorry but I want to understand properly the problem. Lets consider the scenarios again.

A) You have a from1. This form1 has a textBox1 and when some one clicks on the button1 you want to create a form2, set the PassedText and show the result.
If I understood well, this is working fine for you.

B) You have the same form1, but now, when someone clicks on the button3 you want
* create a form3 having a DataGridView,
* pass a text to search in the database,
* fill a datatable with the relevant records found,
* remove the duplicates if any,
* fill the dataGridView with the result and
* show the form3.
If I understood well, this is not working for you.

If this is right, on the button3 Click event you can do:

Dim Obj As New Form3
Obj.PassedText = TextBox1.Text
Obj.Show()
End Sub

Then on the form3 you need to define:

Private _passedText As String

Public Property [PassedText]() As String
Get
Return _passedText
End Get
Set(ByVal Value As String)
_passedText = Value
End Set
End Property

Then on the Form Load event of the form3 you should:

Dim strConn As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Nazneen\Master\Master\Masterdb.mdf;Integrated Security=True;User Instance=True"
Dim conn As New SqlConnection(strConn)
Dim da As New SqlDataAdapter("select * from SchemeKitMaster where filter = '" & _passedText & "';", conn)
Dim ds As New DataSet()
da.Fill(ds, "SchemeKitMaster")
' Filling a employee table 
Dim dt …
lolafuertes 145 Master Poster

As far as I can see, the preview is returning a blank page, because the line

Dim strText As String = Me.ListView1.Text

returns an empty string, as expected because you never filled his text propery.

Probably you should need to do some thing like

Dim strText as String
For Each lvi as ListViewItem in me.ListView1
    For Each lvsi as ListViewSubItem in lvi
        strText &= lvsi.Text & ControlChars.Tab
    Next
    strText &= ControlChars.CrLf
Next

Hope this helps

lolafuertes 145 Master Poster

Can you be so kind to put here your updated code?

thanks in advance

lolafuertes 145 Master Poster

You need separate datasources / binding sources for each combo.

lolafuertes 145 Master Poster

Please, be so kind to post your code here so we can see what the problem is with your databound combobox.

lolafuertes 145 Master Poster

2 options:
a) do not hid the primary key, hid their visibility in the datagridview
b) use an OleDbCommand to upate the database, then refill the datatable and refresh the datagridview.

Hope this helps

lolafuertes 145 Master Poster

You must control the LWin and RWin key codes on the keypreview event on form.

Hope this helps

lolafuertes 145 Master Poster

I reproduced the problem using the following punch_details table definition in SQL 2008:
ColumnName Data Type
empCode int
date date
time time

Then I filled it with your example data and I wrote the following query:

SELECT a.empCode, a.[date], a.[time] AS intime, b.[time] as break_out, c.time as break_in, d.time as outtime
FROM punch_details AS A 
LEFT JOIN punch_details as B on a.empCode = b.empCode and a.date = b.date and  b.[time] > a.[time] 
LEFT JOIN punch_details as C on b.empCode = c.empCode and b.date = c.date and  c.[time] > b.[time] 
LEFT JOIN punch_details as D on c.empCode = d.empCode and c.date = d.date and  d.[time] > c.[time] 
WHERE NOT d.time is null

that produced the following results:

empCode date intime break_out break_in outtime
----------- ---------- ---------------- ---------------- ---------------- ----------------
5001 2011-09-12 09:05:34.0000000 13:05:53.0000000 14:05:22.0000000 18:05:09.0000000
5002 2011-09-12 09:33:13.0000000 13:22:24.0000000 14:33:53.0000000 17:44:34.0000000

(2 row(s) affected)


Hope this helps

lolafuertes 145 Master Poster

Did you tried to use only AnchorStyles.Right for those 2 labels?

BR

lolafuertes 145 Master Poster

Just to clarify, when you say

all the combo boxes are linked to the same table

that means you have a unique datatable as data source for all the comboboxes?
Or you are filling the combobox items using a datareader?

In the first scenario when you select an item in one of the comboboxes, the current record in the datatable will point the the one selected.
Then all the other selected items are bound to the same current record in the datatable. I would suggest to have separate datatables, one for each combobox.

Hope this helps

lolafuertes 145 Master Poster

Maybe you need that:

Dim SplittedLines As New System.Collections.Generic.List(Of String())
Dim sepChars() as Char = {" "c}

For Each strLine In RichTextBox.Lines
 Dim wordsInLine As String() = strLine.Split(sepChars)
 SplittedLines.Add(wordsInLine) 
End For

See the List usage here

Hope this helps

lolafuertes 145 Master Poster

Just can try some thing like:

Dim sepChars() as Char = {" "c}

For Each strLine In RichTextBox.Lines
 Dim wordInLine As String = strLine.Split(sepChars)
 ...
End For

Hope this helps

lolafuertes 145 Master Poster

Please post your updated code

lolafuertes 145 Master Poster

Sorry, this is not shown on your post.

lolafuertes 145 Master Poster

The listbox selected item is always an object.

You can use the TypeOf operator to verify if it is a FileInfo or a DirectoryInfo class object, then act according.

Hope this helps

lolafuertes 145 Master Poster

Probably this is happening because the last addres is always a blank("; ".

To avoid this, I would suggest to do a simple change in the get function to be like:

Do While Not Result.EOF
        If (strEmailAdd.Length>0) Then strEmailAdd  = strEmailAdd & "; "
        strEmailAdd = strEmailAdd & Result("emailAdd")
        Result.MoveNext
    Loop

Hope this helps

lolafuertes 145 Master Poster

I would suggest do some thing like:

Option a:

1) Define the characters to be separators_cahrs
2) Define the valid_result_line
3) Define a boolean to be true is the_previous_charactes_was_a_separator
4) For each character in the strLine
a) if the_previous_charactes_was_a_separator and this character is a separator_char
* Continue the foreach
b) if this character is a separator
* add a predefined separator in the valid result line
* set the_previous_charactes_was_a_separator to be true
* Continue the foreach
c) add the current char to the valid_result_line and set the_previous_charactes_was_a_separator to false
5) Split the line using the predefined separator char.

Option b:

1) Define the characters not_to_be_separators
2) Define the valid_result_line
3) Define a boolean to be true is the_previous_charactes_was_a_separator
4) For each character in the strLine
a) if the_previous_charactes_was_a_separator and this character is a separator char
* Continue the foreach
b) if this character is a separator
* add a predefined separator in the valid result line
* set the_previous_charactes_was_a_separator to be true
* Continue the foreach
c) add the current char to the valid_result_line and set the_previous_charactes_was_a_separator to false
5) Split the line using the predefined separator char.

To determine if the curent char is a separator you can create a function to return if this is a separator char or not depending on the option a or b.

Hope this helps

lolafuertes 145 Master Poster

In order to retrieve data from a database you'll need:

a) Open a connectino to the database
b) Create a SELECT command from the table, filtering the result if needed.
The result of this command can be retieved using 2 ways
* Fill a table in a dataset using a data adapter, then use this table to be the source for your combobox, and refresh the combobox contents
* Create a datareader, clear all items in the combobox, then for each record read by the datareader, add the relevant info to a new combobox item, and finally close the datareader.

As you already experienced using properties, you also can create public subsor functions on the destination forms that do this work. Then calling them from the first form, and passing the appropiate values for filtering, will do the tric.

Hope this helps

lolafuertes 145 Master Poster

IMO you miss to pass the parameters values to the query before executing the insert.


See here for an example.

Hope this helps.

lolafuertes 145 Master Poster

Most propably is that one (or more) of the comboboxes has no SelectedItem.

By default, there is no SelectedItem on a combobox.

To verify if the combo has one, verify that the SelectedIndex value is greater than -1.

Also is a common good practice to verify that all the fields (tex boxes text, and combo boxes selected items ToString, etc.) does not contain an apostrophe before inserting them in a command.

Hope this helps.

lolafuertes 145 Master Poster

Im glad to hear that.

If this thread has been solved, please be so kind to mark it.
Thanks in advance.

lolafuertes 145 Master Poster

I would suggest to put a second eye on the installed languages, the supported codes, and the one used as default language, the default keyboard, and in the regional settings the default number of decimal places for numeric formats.

Also, if the output format is a requirement, i will suggest not to use the default output of ToString() but the appropiate formatting instead.

Hope this helps.

lolafuertes 145 Master Poster

Yes, your father is right. But ...
This is allowed only to users with Admin rights, and givin admin rights only to use IE appears to be risky.

If you want 2 normal users to use the server to navigate with IE, you will need to buy the Terminal Server Services license and CAL and install them.

Hope this helps

lolafuertes 145 Master Poster

Sorry, maybe i need to explain my solution a little bit more...

The part "SELECT DISTINCT Month, Year, 0 as F1, 0 as F2, 0 as F3, 0 As F4 FROM Table" will assure that, for every existing month & year in the database you will always have a record with almost a value of 0. No matter wich customer is. Allways you'll have a record for a month if almost one customer has called this month.

The part "SELECT Month, Year, F1, F2, F3, F4 FROM Table WHERE customer = " & selectedcustomer.text returns all the info from your customer, but in this case, you are unsure to have all the months.

You need to sum both results, the months with 0 values (nothing altered) with the month returned according to the filter applied and yu'll obtain a record for each existing month & year. Here the UNION ALL will return a dataset with 1 or 2 rows by month depending if the custumer has made calls (2) or not (1).

Then, this intermediate result (or sub query) named T, is totalized Grouping by month & year and giving sum of each field for that month year.

If this solution is not supported by your SQL version, then you can do it using the 2 queries (orderd by month & year) then you can cicle over the very first (year & month with 0 values) and search if a record exist in the second …

lolafuertes 145 Master Poster

If you are usiong SQL Server, you can merge a query from your table obtaining an empty structure and the table filtered contents using a union all joint like

SELECT Month, Year, Sum(F1) AS Fi1, Sum(F2) AS Fi2, Sum(F3) as Fi3, Sum(F4) as Fi4 FROM (SELECT DISTINCT Month, Year, 0 as F1, 0 as F2, 0 as F3, 0 As F4 FROM YourTable UNION ALL SELECT Month, Year, F1, F2, F3, F4 FROM YourTable WHERE Customer = '1234') T GROUP BY Month, Year ORDER BY Month, Year;

Hope this helps