Visual Basic

I have a couple of questions:
(1)      The first one question is how many occurrences can you have of  a Database connection string like so: Public con5 As New SqlConnection("Data Source = localhost\GECACSQL; Initial Catalog = Housingtwoyrsbck; Integrated Security= True")
    Public cmd5 As New Data.SqlClient.SqlCommand
(2)      
This is the syntax Error that keep repeating when I try to save 30 Day income calculation to database

Try
            cmd5.CommandType = System.Data.CommandType.Text




            cmd5.CommandText = " insert into 30dayIncome values ('" & txtclnt30dSsn.Text & "','" & txtclntFN.Text & "','" & txtclntLN.Text & "','" & dtpAppdt.Value.Date & "','" & txtdtpApp.Text & "','" & _
                                                                  dtpRng.Value.Date & "','" & txtRng.Text & "','" & txt30FnLncpy.Text & "','" & txtclnt1Income.Text & "','" & txtpaydt1.Text & "','" & txtgrsAmnt1.Text & "','" & _
                                                                  txtsrc2clnt.Text & "','" & txtpdclnt2.Text & "','" & txtgrss2clnt.Text & "','" & txtsrc3clnt.Text & "','" & txtpdt3clnt.Text & "','" & txtgrs3clnt.Text & "','" & _
                                                                  txtsrc4clnt.Text & "','" & txtpdt4clnt.Text & "','" & txtgrs4clnt.Text & "','" & txtErnTotclnt.Text & "','" & txtUnrnMonclt.Text & "','" & txtmem2.Text & "','" & _
                                                                  txtsrc1mem2.Text & "','" & txtpdt1m2.Text & "','" & txtgrsamnt2.Text & "','" & txtsrc2mem2.Text & "','" & txtpdt2m2.Text & "','" & txtgrs2m2.Text & "','" & _
                                                                  txtsrc3m2.Text & "','" & txtpdt3m2.Text & "','" & txtgrs3m2.Text & "','" & txtsrc4m2.Text & "','" & txtpdt4m2.Text & "','" & txtgrs4m2.Text & "','" & txterTm2.Text & "','" & _
                                                                  txtunrTm2.Text & "','" & txtmem3.Text & "','" & txtsrc1m3.Text & "','" & txtpdt1m3.Text & "','" & txtgrs1m3.Text & "','" & txtsrc2m3.Text & "','" & _
                                                                  txtpdt2m3.Text & "','" & txtgrs2m3.Text & "','" & txtsrc3m3.Text & "','" & txtpdt3m3.Text & "','" & txtgrs3m3.Text & "','" & txtsrc4m3.Text & "','" & txtpdt4m3.Text & "','" & _
                                                                  txtgrs4m3.Text & "','" & txternTm3.Text & "','" & txtUnrm3.Text & "','" & txtm4.Text & "','" & txtsrc1m4.Text & "','" & txtpdt1m4.Text & "','" & _
                                                                  txtgrs1m4.Text & "','" & txtsrc2m4.Text & "','" & txtpdt2m4.Text & "','" & txtgrs2m4.Text & "','" & txtsrc3m4.Text & "','" & txtpdt3m4.Text & "','" & txtgrs3m4.Text & "','" & _
                                                                  txtsrc4m4.Text & "','" & txtpdt4m4.Text & "','" & txtgrs4m4.Text & "','" & txternm4.Text & "','" & txtUnrm4.Text & "','" & cmbFpgLmt.SelectedItem & "','" & _
                                                                  cmbFPGYrLmt.SelectedItem & "','" & rdbysFPG.Checked & "','" & rdbnoFpg.Checked & "','" & cmbAMIyr.SelectedItem & "','" & txtfam30d.Text & "','" & rdbysAmi.Checked & "','" & _
                                                                  rdbnoAmi.Checked & "','" & txtgrndTot.Text & "','" & txtmnUnr.Text & "','" & txtnum30.Text & "','" & txtrepwk30.Text & "','" & txtgrssmonth.Text & "','" & _
                                                                  txtEstrnUnr.Text & "','" & txtEstAnn.Text & "','" & txtAnnUnrn.Text & "','" & txtAnnrnUnr.Text & "','" & cmbcnslr30d.SelectedItem & "','" & txtdtsgn.Text & "')"



            cmd5.Connection = con



            con5.Open()
            cmd5.ExecuteNonQuery()
            MsgBox("Succesfully addes", MsgBoxStyle.Information, "add")



        Catch ex As Exception

            MessageBox.Show(ex.Message)

            '  con5.Close()

        End Try
    End Sub

Open in new window

(3)      This button click is the first part of the calculation and the other 4 button are similar the calculation work fine it’s just isn’t being passed to the SQL Database like the other ones are?
Private Sub btnTot1_Click(sender As Object, e As EventArgs) Handles btnTot1.Click

        'This line of code calles Total 1 subroutine.
        'Tot1()

        unrnmon = FormatCurrency(txtUnrnMonclt.Text)

        ' Values are there then Gross Income textboxes are converted to decimal currency values.
        Clngrs1 = FormatCurrency(txtgrsAmnt1.Text)
        Clngrs2 = FormatCurrency(txtgrss2clnt.Text)
        Clngrs3 = FormatCurrency(txtgrs3clnt.Text)
        Clngrs4 = FormatCurrency(txtgrs4clnt.Text)

        'The individual gross incomes are added together for Grand Total * (4.33)for 30 day total
        ernincTot = Clngrs1 + Clngrs2 + Clngrs3 + Clngrs4

        txtErnTotclnt.Text = FormatCurrency(ernincTot * 4.33.ToString)
        hh1erntot = FormatCurrency(txtErnTotclnt.Text)

        grntot30 = FormatCurrency(txtgrndTot.Text)


        Dim strinput1, strinput2 As String
        Dim ysbol, nobol As Boolean

        nobol = False
        ysbol = True

        strinput1 = InputBox(" Does House Hould Member 2 have Income? Enter True or False ")

        If strinput1 = "" Then
            MsgBox(" You canceled ")

        ElseIf strinput1 = nobol Then
            MsgBox(" That's all the House Hold Income! ")



            txtgrndTot.Text = FormatCurrency(txtErnTotclnt.Text)
            txtmnUnr.Text = FormatCurrency(unrnmon.ToString)

        Else
            strinput2 = ysbol

            MsgBox(" You have a second person with income! Your Grand Total is increasing. ")

            grpMem2.Visible = True

            'End If
        End If


    End Sub

Open in new window

(4)
This code is at form load to be recognized throughout Form, I changed it because the Subroutine would not pass to Insert Code from VB to SQL?
Private Sub HousingAppMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load

unrnmon = FormatCurrency(txtUnrnMonclt.Text)

                ernincTot = Clngrs1 + Clngrs2 + Clngrs3 + Clngrs4

        
        grntot30 = FormatCurrency(txtgrndTot.Text)

End Sub

Open in new window

MyExpqust15Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
First - I'd encourage you to NOT ask multiple questions in the same post. Many Experts simply will not attempt to help you with these, since they often become very difficult to follow. Instead, ask 4 separate questions, and handle those individually.

1. As many as you want, although if the string never changes you might consider a Global variable, or adding it to the Application Settings. That said, you should open a connection when you need it, use the connection, then close it immediately. There is no reason to keep your connection open throughout.

2. INSERT statements list the Columns you'll be inserting into first, then the Values:

INSERT INTO SomeTable(Col1, Col2, Col3) VALUES(Val1, Val2, VAl3)

3. I don't see anywhere in your code that you issue any command/statement that would add your data to a database - unless you're using bound controls, in which case you need to check the binding methods to insure you're properly connected to the database.

4. I'm not sure what you're asking here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MyExpqust15Author Commented:
OK let me simplify, although I have to think specifically of what to ask, this means, It would be better if you tell me exactly how I should ask my question. So by the time I ask my question I may have already figured it out.
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
My point is simply this:

You've asked for help with 4 separate issues in your post here, and they're not really related related. Many Experts will see this and will simply not try to help you.

Instead, ask 4 separate questions. You'll find EE will work much better that way.

That said, I've responded to your issues, and what you should do now is review what I've suggested and try to implement that in your own project. If you don't understand something then post back here and ask for clarification, or more help. EE is very much a "two way street" - we don't know if you need more help unless you ask us for it!
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

MyExpqust15Author Commented:
I've requested that this question be deleted for the following reason:

question is to much for expert to answer, need simplified
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I've provided suggestions to all of the Experts requests. I'll be glad to work with you to resolve any issues you have, but you have to provide me with feedback.
0
MyExpqust15Author Commented:
OK Scott, looking forward to working with you, I will be asking more questions next week.

Have a beautiful weekend!
0
Wizer Beauty ProductsCommented:
you can use MSDN to resolve this problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.