?
Solved

ASP.NET command to insert values in sql database: Compiler Error Message: BC30451: Name 'CommandType' is not declared.

Posted on 2004-10-26
4
Medium Priority
?
417 Views
Last Modified: 2008-02-01
Hello!! I have two questions:
1)Is the attached code the best way to insert data in sql database or you will reconmned to use another code?

2)Why it says Compiler Error Message: BC30451: Name 'CommandType' is not declared.

Code


<script runat="server">

      sub Button1_click(Sender As Object, E As EventArgs)

      Dim strConString As String
      Dim conlinklogisticoNET As SqlConnection
     strConString = ConfigurationSettings.AppSettings( "conString" )
      conlinklogisticoNET = New SqlConnection( strConString )

      conlinklogisticoNET.Open()
      Dim cmdinsert As SqlCommand
      cmdinsert = New SqlCommand( "sp_MTotalPurchaseInsert" , conlinklogisticoNET)
     cmdinsert.CommandType = CommandType.StoredProcedure


      Dim param1 as new sqlparameter
      param1.parametername = "@ponumber_x"
      param1.value = ponumber_x.text
      cmdinsert.parameters.add(param1, sqltype.nvarchar, 50)

       Dim param2 as new sqlparameter
      param2.parametername = "@date_x"
      param2.value = date_x.text
      cmdinsert.parameters.add(param2, sqltype.smalldatetime, 4)


       Dim param3 as new sqlparameter
      param3.parametername = "@no_do"
      param3.value = no_do.text
      cmdinsert.parameters.add(param3, sqltype.nvarchar, 50)


       Dim param4 as new sqlparameter
      param4.parametername = "@do_date"
      param4.value = do_date.text
      cmdinsert.parameters.add(param4, sqltype.smalldatetiem, 4)


       Dim param5 as new sqlparameter
      param5.parametername = "@supplier_x"
      param5.value = supplier_x.text
      cmdinsert.parameters.add(param5, sqltype.nvarchar, 50)


       Dim param6 as new sqlparameter
      param6.parametername = "@address"
      param6.value = address.text
      cmdinsert.parameters.add(param6, sqltype.nvarchar, 50)


       Dim param7 as new sqlparameter
      param7.parametername = "@tel"
      param7.value = tel.text
      cmdinsert.parameters.add(param7, sqltype.nvarchar, 50)


       Dim param8 as new sqlparameter
      param8.parametername = "@fax"
      param8.value = fax.text
      cmdinsert.parameters.add(param8, sqltype.nvarchar, 50)


       Dim param9 as new sqlparameter
      param9.parametername = "@email"
      param9.value = email.text
      cmdinsert.parameters.add(param9, sqltype.nvarchar, 50)


       Dim param10 as new sqlparameter
      param10.parametername ="@contact"
      param10.value = contact.text
      cmdinsert.parameters.add(param10, sqltype.nvarchar, 50)


       Dim param11 as new sqlparameter
      param11.parametername = "@city"
      param11.value = city.text
      cmdinsert.parameters.add(param11, sqltype.nvarchar, 50)


       Dim param12 as new sqlparameter
      param12.parametername = "@country"
      param12.value = country.text
      cmdinsert.parameters.add(param12, sqltype.nvarchar, 50)


       Dim param13 as new sqlparameter
      param13.parametername = "@buyer"
      param13.value = buyer.text
      cmdinsert.parameters.add(param13, sqltype.nvarchar, 50)


       Dim param14 as new sqlparameter
      param14.parametername = "@job"
      param14.value = job.text
      cmdinsert.parameters.add(param14, sqltype.nvarchar, 50)


       Dim param15 as new sqlparameter
      param15.parametername ="@emailbuyer"
      param15.value = emailbuyer.text
      cmdinsert.parameters.add(param15, sqltype.nvarchar, 50)

       Dim param16 as new sqlparameter
      param16.parametername = "@telbuyer"
      param16.value = telbuyer.text
      cmdinsert.parameters.add(param16, sqltype.nvarchar, 50)


       Dim param17 as new sqlparameter
      param17.parametername = "@client_name"
      param17.value = client_name.text
      cmdinsert.parameters.add(param17, sqltype.nvarchar, 50)


       Dim param18 as new sqlparameter
      param18.parametername = "@division_x"
      param18.value = division_x.text
      cmdinsert.parameters.add(param18, sqltype.decimal, 9)


       Dim param19 as new sqlparameter
      param19.parametername = "@via"
      param19.value = via.text
      cmdinsert.parameters.add(param19, sqltype.nvarchar, 50)


       Dim param20 as new sqlparameter
      param20.parametername = "@incoterms"
      param20.value = incoterms.text
      cmdinsert.parameters.add(param20, sqltype.nvarchar, 50)


       Dim param21 as new sqlparameter
      param21.parametername =  "@shipport"
      param21.value =  shipport.text
      cmdinsert.parameters.add(param21, sqltype.nvarchar, 50)


       Dim param22 as new sqlparameter
      param22.parametername = "@shipdestiny"
      param22.value = shipdestiny.text
      cmdinsert.parameters.add(param22, sqltype.nvarchar, 50)


       Dim param23 as new sqlparameter
      param23.parametername = "@cargo"
      param23.value = cargo.text
      cmdinsert.parameters.add(param23, sqltype.nvarchar, 50)


       Dim param24 as new sqlparameter
      param24.parametername = "@viapriority"
      param24.value = viapriority.text
      cmdinsert.parameters.add(param24, sqltype.nvarchar, 50)


       Dim param25 as new sqlparameter
      param25.parametername = "@shipto"
      param25.value = shipto.text
      cmdinsert.parameters.add(param25, sqltype.nvarchar, 50)



       Dim param26 as new sqlparameter
      param26.parametername ="@billto"
      param26.value = billto.text
      cmdinsert.parameters.add(param26, sqltype.nvarchar, 50)


        Dim param27 as new sqlparameter
      param27.parametername = "@notes"
      param27.value = notes.text
      cmdinsert.parameters.add(param27, sqltype.nvarchar, 2000)



    cmdinsert.executenonquery()
   conlinklogisticoNET.close()

    end sub

</script>
<html>
<head>
    <link href="..\styles\stylesheetwl.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <form id="form" runat="server">
        <table marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
            <tbody>
                <tr class="subtitle">
                    <td colspan="2">
                        <asp:Label id="poinfo" runat="server" width="240px">Orden de Compra</asp:Label></td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lponumber_x" runat="server">Orden Compra</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="ponumber_x" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="ldate_x" runat="server">Fecha</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="date_x" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lno_do" runat="server">No Do</asp:Label>&nbsp;
                    </td>
                    <td class="r">
                        <asp:TextBox id="no_do" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="ldo_date" runat="server">Fecha Do</asp:Label>&nbsp;</td>
                    <td class="r">
                        <asp:TextBox id="do_date" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="subtitle">
                    <td colspan="2">
                        <asp:Label id="supplierinfo" runat="server" width="245px">Informacin Proveedor</asp:Label></td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lsupplier_x" runat="server">Proveedor</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="supplier_x" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="laddress" runat="server">Dirección</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="address" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="ltel" runat="server">Teléfono</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="Tel" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lfax" runat="server">Fax</asp:Label></td>
                    <td>
                        <asp:TextBox id="fax" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lemail" runat="server">Email</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="email" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lcontact" runat="server">Contacto</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="contact" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lcity" runat="server">Ciudad</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="city" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lcountry" runat="server">Pais</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="country" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="subtitle">
                    <td colspan="2">
                        <asp:Label id="buyerinfo" runat="server" width="245px">Información Comprador</asp:Label></td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lbuyer" runat="server">Comprador</asp:Label>Comprador</td>
                    <td class="r">
                        <asp:TextBox id="buyer" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="ljob" runat="server">Cargo</asp:Label>Cargo</td>
                    <td class="r">
                        <asp:TextBox id="job" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lemailbuyer" runat="server">Email</asp:Label>Email
                    </td>
                    <td class="r">
                        <asp:TextBox id="emailbuyer" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="ltelbuyer" runat="server">Tel</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="telbuyer" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lclient_name" runat="server">Cliente</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="client_name" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="ldivision_x" runat="server">Código Empresa</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="division_x" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="subtitle">
                    <td>
                        <asp:Label id="shippinginfo" runat="server">Instrucciones de Embarque</asp:Label></td>
                    <td>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lvia" runat="server">Medio Transporte</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="via" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lincoterms" runat="server">Incoterms</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="incoterms" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lshipport" runat="server">Puerto Embarque</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="shipport" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lshipdestiny" runat="server">Puerto Destino</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="shipdestiny" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lcargo" runat="server">Transportador</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="cargo" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lviapriority" runat="server">Prioridad Transporte</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="viapriority" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lshipto" runat="server">Embarcar a</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="shipto" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lbillto" runat="server">Facturar a</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="billto" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="1">
                    <td class="l">
                        <asp:Label id="lnotes" runat="server">Notas</asp:Label></td>
                    <td class="r">
                        <asp:TextBox id="notes" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="2">
                    <td class="l">
                        <asp:Label id="lsystemdate" runat="server">Systemdate</asp:Label></td>
                    <td class="r">
                        <input type="hidden" name="systemdate" />
                    </td>
                </tr>
                <tr>
                    <td class="r" colspan="2">
                        <input type="reset" value="Reset" />
                        <asp:Button id="Button1" runat="server" onclick="Button1_click" Text="Submit"></asp:Button>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>

 
0
Comment
Question by:robossa
  • 2
4 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 12415334
One thing I noticed (not related to your problem) is that you have a typo for parameter 4
smalldatetiem --> smalldatetime

I am looking at the error...
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 12416036
Have you tried adding the following imports?

Imports System.Data
Imports System.Data.SqlClient
0
 

Expert Comment

by:genXerator
ID: 12418188
i agree with mrichmon.  if it says CommandType is not declared, I imagine it is because of the line:

cmdinsert.CommandType = CommandType.StoredProcedure

If the appropriate classes are not present, it doesn't know what CommandType is.
0
 

Author Comment

by:robossa
ID: 12437110
It is working after including imports system.data. Thanks a lot  mrichmon. For genxerator, I kept the line cmdinsert thanks a lot.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
Why WooCommerce is one of the majorly favored choices when it comes to having an eCommerce store. This article will acquaint you with some reasons that I believe make it one of the best eCommerce platforms available.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month6 days, 16 hours left to enroll

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question