0

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>
5
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by mahendrabilla
0

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?

0

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!

0

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 & "');"

0

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 & "')"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.