demausdauth's Profile User Rating: -----

Reputation: 177 Stalwart
Group:
Expert
Active Posts:
641 (0.38 per day)
Joined:
03-February 10
Profile Views:
12,877
Last Active:
User is offline Today, 06:31 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Saturn
Dream Kudos:
50
Icon   demausdauth Getting frustrated with paydays -- nothing left :(

Posts I've Made

  1. In Topic: Auto Increment Id in textbox of visual basic 2010 express form

    Posted 28 Aug 2014

    Something to keep in mind when querying to get the next ID value from a database:
    • Are there are multiple users?
    • With multiple users
      • when they query do they get the same 'next Id'?
      • if they do how do you resolve save issues?
      • if not are you saving an empty row to save their place in the database?
      • if that is the case what about abandoned attempts?


    Just some things to think about.
  2. In Topic: many data with few textboxs

    Posted 28 Aug 2014

    Think about what you need the controls on your form to do.
    It seems like you want your button to have 2 responsibilities - initially load your data into your grid and also to add new data to the grid. What I would do is apply some SOLID principles and separate out the responsibility of what some methods do.

    For instance - maybe you should have a method to initially load the data to the grid, one for adding rows of data to the grid, one for saving data to the database, one for querying the database.

    Another thing to think about is this - you want to add a row to your datagridview, but in your code you don't actually seem to be doing anything that would add to your datagridview. If you are following the flow of - add the textbox data to bindingsource and then re query to fill the datagridview again, it doesn't seem to me to that the data in the binding source is being saved to the database. Granted I don't/haven't used the BindingSource myself so I don't know the subtleties of this control, but it doesn't appear that the textbox data is being persisted to the database.

    Last thought - sometimes you have to go back to square one. Get your code to do one thing at a time, add buttons to perform a specific function - load data, save textboxes to grid, save to database, etc... once you have these specific processes working, you can start to combine them (if necessary).
  3. In Topic: Auto Increment Id in textbox of visual basic 2010 express form

    Posted 28 Aug 2014

    What I would do is setup the table in MySQL to autoincrement the Id field - then you only need to ask for the first and last name. When you save the first and last name to the database you should be able to return the generated Id value and then you can display it as saved.
  4. In Topic: VB.net 2008 do while loop processing very slow

    Posted 29 Jul 2014

    I would guess that it is related to opening and closing the sql connection on each iteration of the Do/While. Perhaps you can move that outside of the loop:

    TextBox8.Text = "0"
            Dim val1 As Integer = 0
            Dim val2 As Integer = 0
            val1 = CInt(TextBox3.Text)
            val2 = CInt(TextBox7.Text)
            TextBox8.Text = val1 * val2
            DateTimePicker2.Value = DateTimePicker1.Value.AddDays(Integer.Parse(TextBox8.Text))
    
            Dim pplamt As Integer = 0
            Dim intamt As Integer = 0
            pplamt = CInt(TextBox2.Text.ToString)
            TextBox14.Text = "0"
            Dim index As Integer = 0
            Dim tdate As DateTime = DateTimePicker1.Value.Date
            Dim tot1 As Integer = 0
            Dim tot2 As Integer = 0
            tot1 = CInt(TextBox12.Text.ToString)
            Dim totint As Integer = 0
    
            'the using will automatically dispose of the sql connection for you when it is done
            Using conn As New SqlConnection(str_con)
    
                Do While index <= CInt(TextBox8.Text.ToString)
                    index += 1
                    tot2 += 1
                    If index > CInt(TextBox8.Text.ToString) Then
                        Exit Do
                    End If
    
                    DateTimePicker3.Value = DateTimePicker3.Value.AddDays(Integer.Parse(TextBox14.Text))
                    DateTimePicker2.Value = DateTimePicker3.Value
                    TextBox14.Text = "1"
                    TextBox10.Text = index
                    TextBox11.Text = DateTimePicker3.Value.Date
                    intamt = pplamt * (CInt(Label12.Text.ToString) / 100 / 365)
                    totint += intamt
    
                    Dim tv1 As Decimal = 0
                    tv1 = CInt(TextBox10.Text).ToString
    
                    If Not conn.State = ConnectionState.Open Then
                        conn.Open()
                    End If
    
                    'using will automatcally dispose of the command object for you but the connection object should still be available for the next itteration
                    Using comm As New SqlCommand("INSERT INTO fdmatcalc (fd_number,sl_no,date_start,ppl_amt,int_amt) values(@paramTextBox1, @paramTv1, @paramDateTime, @paramPplamt, @paramIntamt)", conn)
    
                        comm.CommandType = CommandType.Text
    
                        'Add the parameters
                        Dim sqlParameter As SqlParameter
    
                        'add textbox value
                        sqlParameter = New SqlParameter("@paramTextBox1", TextBox1.Text)
                        'add it to the command object
                        comm.Parameters.Add(sqlParameter)
    
                        'add the tv1 value  -- need to create a new parameter object
                        sqlParameter = New SqlParameter("@paramTv1", tv1)
                        'add to the command object
                        comm.Parameters.Add(sqlParameter)
    
                        'add the datetime value  -- need to create a new parameter object
                        sqlParameter = New SqlParameter("@paramDateTime", DateTimePicker3.Value.Date)
                        'add to the command object
                        comm.Parameters.Add(sqlParameter)
    
                        'add the pplamt value  -- need to create a new parameter object
                        sqlParameter = New SqlParameter("@paramPplamt", pplamt)
                        'add to the command object
                        comm.Parameters.Add(sqlParameter)
    
                        'add the intamt value  -- need to create a new parameter object
                        sqlParameter = New SqlParameter("@paramIntamt", intamt)
                        'add to the command object
                        comm.Parameters.Add(sqlParameter)
    
    
                        'all parameters added - execute the query
                        comm.ExecuteNonQuery()
    
                    End Using
    
    
    
                    If Label13.Text = "Daily" Then
                        pplamt = pplamt + intamt
                    End If
                    If Label13.Text <> "Daily" Then
                        If tot1 = tot2 Then
                            pplamt = pplamt + totint
                            tot2 = 0
                        End If
                    End If
                Loop
            End Using
    
    
    


    Also maybe there is a better way to do what you are trying to do - you should maybe re-examine your logic flow.
  5. In Topic: change numbers into order

    Posted 28 Jul 2014

    You could also use and an enum
    Public Enum Order
         None = 0
         First = 1
         Second = 2
         Third = 3
    End Enum
    
    

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
February 2
Gender:
Location:
Minnesota
Interests:
my family, reading, programming,
Full Name:
Aaron
Years Programming:
6
Programming Languages:
VB.NET, C#.NET, ASP.NET, SharePoint 2007 development

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    .nethelp Icon

    07 Apr 2012 - 14:31
    why did u put -1 on my reputation coz u know better? werent u like me before ? thanks anyways this truely shows ur good spirit and what a good mentor u are .
    bye
  2. Photo

    .nethelp Icon

    07 Apr 2012 - 14:31
    why did u put -1 on my reputation coz u know better? werent u like me before ? thanks anyways this truely shows ur good spirit and what a good mentor u are .
    bye
  3. Photo

    Guest 

    29 Jun 2010 - 13:54
    http://www.dreamincode.net/forums/topic/179550-updatepanels-placeholders-and-usercontrols/
  4. Photo

    joker_1 Icon

    13 Jun 2010 - 21:37
    Hi quick question.. What is the "e" argument??
    thanks heaps
  5. Photo

    demausdauth Icon

    11 Jun 2010 - 06:05
    lol -- not trying to break any records
  6. Photo

    CharlieMay Icon

    10 Jun 2010 - 18:31
    Just wanted to say, you keep answering questions like you do and your rep is going to sky-rocket.
Page 1 of 1