Click here to Skip to main content
15,894,050 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Dim cmd As New SqlCommand("insert into Baseline(RegNo,HouseNo,FamilyNo,Name,Fname,Employmentstatus,Typeofwork,Gender,[Family members under age of 15],[Family members between age of 15 and 64],[Family members above age of 64/],[Widow],[Blind or very poor eye sight],[Deaf],[Cripple],[How many family members of 15 years and older can read and write],[Returnee from abroad],[Date of last departure  from Host Country],[Date of arrival in present location],[Host country],[Resident in the city >10 years],[Reason for coming to the area],[Municipality tax  Notebook],[Access to Educational institutions],[Access to Health care Centers],[Main source of drinking water],[Main type of latrine],[Drain and street existing condition],[Entitlement status of shelter],[Type of shelter],[Acces to Transport],[Improvement of street and drain],[Potable water],[Latrines],[Clinic],[Formal school],[Literacy course],[Carpet waving],[Health Training],[Computer Training],[Tailoring Training],[Others],[Community contribution in prioritized project],[Name of information provider]) Values(@RegNo,@HouseNo,@FamilyNo,@Name,@Fname,@Employmentstatus,@Typeofwork,@Gender,[@Family members under age of 15],[@Family members between age of 15 and 64],[@Family members above age of 64/],[@Widow],[@Blind or very poor eye sight],[@Deaf],[@Cripple],[@How many family members of 15 years and older can read and write],[@Returnee from abroad],[@Date of last departure  from Host Country],[@Date of arrival in present location],[@Host country],[@Resident in the city >10 years],[@Reason for coming to the area],[@Municipality tax  Notebook],[@Access to Educational institutions],[@Access to Health care Centers],[@Main source of drinking water],[@Main type of latrine],[@Drain and street existing condition],[@Entitlement status of shelter],[@Type of shelter],[@Acces to Transport],[@Improvement of street and drain],[@Potable water],[@Latrines],[@Clinic],[@Formal school],[@Literacy course],[@Carpet waving],[@Health Training],[@Computer Training],[@Tailoring Training],[@Others],[@Community contribution in prioritized project],[@Name of information provider])", cn)

        With cmd.Parameters
            .AddWithValue("@RegNo", txtreg.Text)
            .AddWithValue("@HouseNo", txthouse.Text)
            .AddWithValue("@FamilyNo", txtfamily.Text)
            .AddWithValue("@Name", txtname.Text)
            .AddWithValue("@Fname", txtfname.Text)
            If rbtnempyes.Checked = True Then
                .AddWithValue("@Employmentstatus", rbtnempyes.Text)
            Else
                .AddWithValue("@Employmentstatus", rbtnempno.Text)
            End If
            .AddWithValue("@Typeofwork", cmbwork.Text)
            .AddWithValue("@Gender", cmbgender.Text)
            .AddWithValue("[@Family members under age of 15]", txt15.Text)
            .AddWithValue("[@Family members between age of 15 and 64]", txt64.Text)
            .AddWithValue("[@Family members above age of 64/]", txtabove64.Text)

            .AddWithValue("[@Widow]", SqlDbType.Int).Value = txtwidow.Text

            .AddWithValue("[@Blind or very poor eye sight]", txtblind.Text)
            .AddWithValue("[@Deaf]", txtdeaf.Text)
            .AddWithValue("@[Cripple]", txtcripple.Text)
            .AddWithValue("[@How many family members of 15 years and older can read and write]", txtlitracy.Text)
            If rbtnyesret.Checked = True Then
                .AddWithValue("[@Returnee from abroad]", rbtnyesret.Text)
            Else
                .AddWithValue("[@Returnee from abroad]", rbtnnoretur.Text)
            End If
            .AddWithValue("[@Date of last departure  from Host Country]", datedepar.Value)
            .AddWithValue("[@Date of arrival in present location]", datearrival.Value)
            .AddWithValue("[@Host country]", cmbhost.Text)
            If rbtnyesresidentsinthecity.Checked = True Then
                .AddWithValue("[@Resident in the city >10 years]", rbtnyesret.Text)
            Else
                .AddWithValue("[@Resident in the city >10 years]", rbtnnoresidentsinthecity.Text)
            End If
            .AddWithValue("[@Reason for coming to the area]", cmbreasonforcommingaerea.Text)
            If rbtnyesmunacipilty.Checked = True Then
                .AddWithValue("[@Municipality tax  Notebook]", rbtnyesmunacipilty.Text)
            Else
                .AddWithValue("[@Municipality tax  Notebook]", rbtnnomunacipilty.Text)
            End If
            .AddWithValue("[@Access to Educational institutions]", cmbaccesseducation.Text)
            .AddWithValue("[@Access to Health care Centers]", cmbaccesstohealth.Text)
            .AddWithValue("[@Main source of drinking water]", cmbwater.Text)
            .AddWithValue("[@Main type of latrine]", cmblatrine.Text)
            .AddWithValue("[@Drain and street existing condition]", cmbdrain.Text)
            .AddWithValue("[@Entitlement status of shelter]", cmbstatusshelter.Text)
            .AddWithValue("[@Type of shelter]", cmbtpyeshelter.Text)
            .AddWithValue("[@Acces to Transport]", cmbaccesstotransport.Text)
            .AddWithValue("[@Improvement of street and drain]", cmbpublicneed.Text)
            .AddWithValue("[@Potable water]", cmbpublicneed.Text)
            .AddWithValue("[@Latrines]", cmbpublicneed.Text)
            .AddWithValue("[@Clinic]", cmbpublicneed.Text)
            .AddWithValue("[@Formal school]", cmbpublicneed.Text)
            .AddWithValue("[@Literacy course]", cmbneedfordifferent.Text)
            .AddWithValue("[@Carpet waving]", cmbneedfordifferent.Text)
            .AddWithValue("[@Health Training]", cmbneedfordifferent.Text)
            .AddWithValue("[@Computer Training]", cmbneedfordifferent.Text)
            .AddWithValue("[@Tailoring Training]", cmbneedfordifferent.Text)
            .AddWithValue("[@Others]", cmbneedfordifferent.Text)
            .AddWithValue("[@Community contribution in prioritized project]", txtcommunity.Text)
            .AddWithValue("[@Name of information provider]", txtnameprovider.Text)

            If cn.State = ConnectionState.Closed Then
                cn.Open()
            End If
            cmd.ExecuteNonQuery()

            MsgBox("Record is Successfully Saved", MsgBoxStyle.Information)



        End With
Posted
Updated 6-Aug-15 0:13am
v2

1 solution

A parameter name cannot have a space (or other illegal characters) in it.
I'd recommend changing them all e.g. from

[@Family members under age of 15]

to

@Family_Members_under_age_of_15
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900