hi there,
im having problem with the whole codings here. i can't execute the programme.please help.tell me whats my mistake. i need to connect it to the microsoft sql server

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">
   function SelectAll(id){
      var frm =document.forms[0];
         for(id=0;id<frm.elements.length;i++){
             if(frm.elements[i].type=="checkbox"){
                      frm.elements[i].checked-document.getElementById(id).checked;
             }
          }
       }
       </script>
       
       <asp:Gridview Id="Gridview1" runat="server" DataSourceID="SqlDataSource1">
          <columns>
               <asp:TemplateField>
               <AlternatingItemTemplate>
                     <asp:CheckBox ID="CheckBox1" runat="server"/>
                     </AlternatingItemTemplate>
                     <ItemTemplate>
                          
                     <asp:CheckBox ID="CheckBox1" runat ="server"/>
                     </ItemTemplate>
                     
                         <HeaderStyle HorizontalAlign="left" />
                         <ItemStyle Horizontalalign="left" />
                     
               </asp:TemplateField>
                             
            </columns>
       </asp:Gridview>
       
       
    
       
       
<script runat="server">
    
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim MyConnection As SqlConnection
        Dim MyCommand As SqlCommand
        
    
        
        
        MyConnection = New SqlConnection()
        MyConnection.ConnectionString = _
        ConfigurationManager.ConnectionStrings("MainConnStr").ConnectionString
    Dim str As String = "insert into Registration(AccountNum, ContactPerson , FaxNum, City, Poskod,Address,EmailAdd,H/Pnum,State) " + "values ('" &TextBox1.Text& "','" &TextBox2.Text& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" & TextBox8.Text & "','" & TextBox9.Text & "');"
        
        
        MyCommand = New SqlCommand
    End Sub
    
    Protected Sub Gridview1_RowDataBound(ByVal sender As Object,ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs e){
        If (e.Row.RowType = DataControlRowType.Header) Then
            'adding an attribute for onclick event on the check box header
            'and passing the ClientID of the Select All checkbox
            DirectCast(e.Row.FindControl("CheckBox1"), CheckBox).Attributes.Add)"OnClick","javascript.SelectAll('" + ((CheckBox1)
            e.Row.FindControl("CheckBox1"), CheckBox).ClientID & "')");
            
        End If
    End Sub
    

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <p>
        <br />
    </p>
    <form id="form1" runat="server">
    <div>
    
        <br />
        <br />
        <br />
        PICK UP FORM</div>
    <p>
        &nbsp; &nbsp;</p>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <p>
&nbsp;Account Number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </p>
    <p>
        Contact Person&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </p>
    <p>
        Fax Number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    </p>
    <p>
        City&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
    </p>
    <p>
        Poskod&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
    </p>
    <p>
        Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
    </p>
    <p>
        Email address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
    </p>
    <p>
        Phone Number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
    </p>
    <p>
        State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
    </p>
    <p>
        E Shipping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:CheckBox ID="CheckBox1" runat="server" />
        
    </p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="Button1" runat="server" Text="Button" Width="84px" />
    </form>
</body>
</html>

hi

change your SQL statement to this

"insert into Registration(AccountNum, ContactPerson , FaxNum, City, Poskod,Address,EmailAdd,H/Pnum,State) values ('" &TextBox1.Text& "','" &TextBox2.Text& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" & TextBox8.Text & "','" & TextBox9.Text & "');"

removed the " + " before Value

Are you getting any specific error messages?

Hi,

we use

'"&TextBox1.Text&"' for vb
'"+TextBox1.Text+"' for c#

only meant to say i had removed from the values clause in the sql statement - it was like this '" + "values'

Not that i had removed it from any of the input values

Apologies, didnt mean to cause any confusion!

thank you ive got the point. it works

sorry, now im getting an error.it says "end of statement expected" by underlining the below...please help
('" &TextBox1.Text& "','" &TextBox2.Text& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" & TextBox8.Text & "','" & TextBox9.Text & "');"
"insert into Registration(AccountNum, ContactPerson , FaxNum, City, Poskod,Address,EmailAdd,H/Pnum,State) values ('" &TextBox1.Text& "','" &TextBox2.Text& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" & TextBox8.Text & "','" & TextBox9.Text & "');"

JUST TRY TO CHANGE THE BELOW LINE:

TextBox9.Text & "');"

BY

TextBox9.Text & "')";

Check with the below syntax

Dim str As String =
"insert into Registration(AccountNum, ContactPerson , FaxNum, City, Poskod,Address,EmailAdd,H/Pnum,State) values ('" &TextBox1.Text& "','" &TextBox2.Text& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" & TextBox8.Text & "','" & TextBox9.Text & "')"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.