469,613 Members | 1,874 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

help submitting info into my access database - VB, ASP.NET

I am building an Eccomerce site and I am trying to make my shopping cart work. I am having a problem with when I have entered data into my form it is not submitting into my access database. This my coding for my page. I am very new at all this and any help with be most appreciated.
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="vb" Debug="True"%>
  2. <%@ Import Namespace="System.Data" %>
  3. <%@ Import Namespace="System.Data.OleDb" %>
  4. <%@ Import Namespace="System.Drawing" %>
  5. <SCRIPT Runat="Server">
  6.  
  7.     Sub Page_Load()
  8.  
  9.         If Not Page.IsPostBack Then
  10.             ReturnURL.Text = Request.Form("ReturnURL")
  11.             MerchantID.Text = Request.Form("MerchantID")
  12.             CustomerID.Text = Request.Form("CustomerID")
  13.             OrderTotal.Text = String.Format("{0:C}", Request.Form("OrderTotal"))
  14.         End If
  15.  
  16.     End Sub
  17.  
  18.     Sub Check_Credit(ByVal Src As Object, ByVal Args As EventArgs)
  19.  
  20.         Dim ValidEmail As Boolean = True
  21.         If Email.Text <> "" Then
  22.             If InStr(Email.Text, "@") = 0 Then
  23.                 ValidEmail = False
  24.                 Message.Text = "Invalid email address"
  25.             ElseIf Mid(Email.Text, Len(Email.Text) - 3, 1) <> "." Then
  26.                 ValidEmail = False
  27.                 Message.Text = "Invalid email address"
  28.             End If
  29.         Else
  30.             ValidEmail = False
  31.             Message.Text = "Missing email address"
  32.         End If
  33.  
  34.         If ValidEmail = True Then
  35.             CreditCard.Enabled = False
  36.             Account.Enabled = False
  37.             ExpMonth.Enabled = False
  38.             ExpYear.Enabled = False
  39.             Name.Enabled = False
  40.             Address.Enabled = False
  41.             City.Enabled = False
  42.             State.Enabled = False
  43.             Zip.Enabled = False
  44.             Email.Enabled = False
  45.  
  46.             Instructions.Text = "Click the ""Complete Order"" button to " & _
  47.                                 "complete your order with "
  48.             Approved.Text = "Approved"
  49.             ContinuePanel.Visible = False
  50.             CompletePanel.Visible = True
  51.         End If
  52.  
  53.     End Sub
  54.  
  55.     Sub Submit_Order(ByVal Src As Object, ByVal Args As EventArgs)
  56.         SubmitForm = True
  57.  
  58.         Dim DBConnection As OleDbConnection
  59.         Dim SQLString As String
  60.  
  61.  
  62.  
  63.  
  64.  
  65.         DBConnection = New OleDbConnection( _
  66.              "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  67.              "Data Source=" & Server.MapPath("~/database/beanroasted.mdb"))
  68.         DBConnection.Open()
  69.  
  70.         SQLString = "INSERT INTO Orders " _
  71.              & "(CustomerID, CreditCard, ExpMonth, Name, Address, City, State, Zip, Email) " _
  72.               & "VALUES (" & CustomerID.Text & ", " _
  73.               & CreditCard.SelectedValue & ", " _
  74.               & ExpMonth.SelectedValue & ", " _
  75.               & "'" & Name.Text & "',  " _
  76.               & "'" & Address.Text & "', " _
  77.               & "'" & City.Text & "', " _
  78.               & "'" & State.Text & "', " _
  79.               & Zip.Text & ", " _
  80.               & "'" & Email.Text & "')"
  81.  
  82.  
  83.  
  84.  
  85.     End Sub
  86.  
  87.     Dim SubmitForm As Boolean = False
  88.  
  89.  
  90.     Sub Cancel_Order(ByVal Src As Object, ByVal Args As EventArgs)
  91.         Approved.Text = "Cancel"
  92.         Submit_Order(Nothing, Nothing)
  93.     End Sub
  94.  
  95.  
  96.  
  97. </SCRIPT>
  98.  
  99.  
  100. <html>
  101. <head>
  102.   <title>Credit Check</title>
  103.  
  104. </head>
  105. <body>
  106. <form id="Form1" Runat="Server">
  107.  
  108. <table id="MasterTable" border="0" cellspacing="0" width="100%">
  109. <tr>
  110.   <td id="HeaderCell">
  111.     webWarehouse.com
  112.   </td>
  113. </tr>
  114. </table>
  115. <br/>
  116.  
  117. <asp:Label id="ReturnURL" Visible="False" Runat="Server"/>
  118.  
  119. <asp:Label id="Instructions" Runat="Server"
  120.   Text="Enter the requested information to complete your order with "/>
  121. <asp:Label id="MerchantID" Font-Bold="True" Runat="Server"/>.<br/><br/>
  122.  
  123. <table border="0">
  124. <tr>
  125.   <th> Customer ID: </th>
  126.   <td colspan="5">
  127.     <asp:Label id="CustomerID" Runat="Server"
  128.       Font-Bold="True"/>
  129.     <asp:Label id="Approved" Runat="Server"
  130.       ForeColor="#FF0000" Font-Bold="True"/>
  131.   </td>
  132. </tr>
  133. <tr>
  134.   <th> Order Amount: </th>
  135.   <td colspan="5">
  136.     <asp:Label id="OrderTotal" Runat="Server"
  137.       Font-Bold="True"/></td>
  138. </tr>
  139. <tr>
  140.   <td colspan="6"> </td>
  141. </tr>
  142. <tr>
  143.   <th> Credit Card: </th>
  144.   <td colspan="5">
  145.     <asp:DropDownList id="CreditCard" Runat="Server">
  146.       <asp:ListItem>Discover</asp:ListItem>
  147.       <asp:ListItem>MasterCard</asp:ListItem>
  148.       <asp:ListItem>Visa</asp:ListItem>
  149.       <asp:ListItem>Discover</asp:ListItem>
  150.     </asp:DropDownList>
  151.   </td>
  152. </tr>
  153. <tr>
  154.   <th> Account: </th>
  155.   <td colspan="5">
  156.     <asp:TextBox id="Account" Runat="Server"
  157.       Text="1111 1111 1111 1111" Size="16" MaxLength="19"/>
  158.   </td>
  159. </tr>
  160. <tr>
  161.   <th> Expiration Date: </th>
  162.   <td colspan="5">
  163.     Month: 
  164.     <asp:DropDownList id="ExpMonth" Runat="Server">
  165.       <asp:ListItem>01</asp:ListItem>
  166.       <asp:ListItem>02</asp:ListItem>
  167.       <asp:ListItem>03</asp:ListItem>
  168.       <asp:ListItem>04</asp:ListItem>
  169.       <asp:ListItem>05</asp:ListItem>
  170.       <asp:ListItem>06</asp:ListItem>
  171.       <asp:ListItem>07</asp:ListItem>
  172.       <asp:ListItem>08</asp:ListItem>
  173.       <asp:ListItem>09</asp:ListItem>
  174.       <asp:ListItem>10</asp:ListItem>
  175.       <asp:ListItem>11</asp:ListItem>
  176.       <asp:ListItem>12</asp:ListItem>
  177.     </asp:DropDownList>
  178.     Year: 
  179.     <asp:DropDownList id="ExpYear" Runat="Server">
  180.       <asp:ListItem>2003</asp:ListItem>
  181.       <asp:ListItem>2004</asp:ListItem>
  182.       <asp:ListItem>2005</asp:ListItem>
  183.       <asp:ListItem>2006</asp:ListItem>
  184.       <asp:ListItem>2007</asp:ListItem>
  185.     </asp:DropDownList>
  186.   </td>
  187. </tr>
  188. <tr>
  189.   <td colspan="6"> </td>
  190. </tr>
  191. <tr>
  192.   <th> Name: </th>
  193.   <td colspan="5">
  194.     <asp:TextBox id="Name" Runat="Server" 
  195.       Text="Your Name" Size="30" MaxLength="50"/></td>
  196. </tr>
  197. <tr>
  198.   <th> Address: </th>
  199.   <td colspan="5">
  200.     <asp:TextBox id="Address" Runat="Server" 
  201.       Text="Your Address" Size="30" MaxLength="50"/></td>
  202. </tr>
  203. <tr>
  204.   <th> City: </th>
  205.   <td><asp:TextBox id="City" Runat="Server"
  206.     Text="Your City" Size="30" MaxLength="30"/></td>
  207.   <th> State: </th>
  208.   <td><asp:TextBox id="State" Runat="Server"
  209.     Text="ST" Size="2" MaxLength="2"/></td>
  210.   <th> Zip: </th>
  211.   <td><asp:TextBox id="Zip" Runat="Server"
  212.     Text="55555" Size="10" MaxLength="10"/></td>
  213. </tr>
  214. <tr>
  215.   <th> Email: </th>
  216.   <td colspan="5">
  217.     <asp:TextBox id="Email" Runat="Server"
  218.       Text="your@email.net" Size="30" MaxLength="50"/></td>
  219. </tr>
  220. </table><br/>
  221.  
  222. <asp:Panel id="ContinuePanel" Runat="Server">
  223.   <asp:Button id="ContinueButton" Text="Continue Purchase" Runat="Server" OnClick="Check_Credit"/>
  224.   <asp:Button id="CancelButton" Text="Return to Shopping" Runat="Server" OnClick="Cancel_Order"/>
  225.   <asp:Label id="Message" EnableViewState="False" Runat="Server" style="color:#FF0000"/>
  226. </asp:Panel>
  227.  
  228. <asp:Panel id="CompletePanel" Visible="False" Runat="Server">
  229.   Click to
  230.   <asp:Button ID="Button1" Text="Complete Order" Runat="Server"
  231.     OnClick="Submit_Order"/>
  232.   or
  233.   <asp:Button ID="Button2" Text="Return to Shopping" Runat="Server"
  234.     OnClick="Cancel_Order"/>
  235. </asp:Panel>
  236.  
  237. </form>
  238. <form name="ReturnOrder" action='<%= ReturnURL.Text %>' method="post">
  239.  
  240. <input type="hidden" name="ReturnApproved" value='<%= Approved.Text %>'/>
  241. <input type="hidden" name="ReturnMerchantID" value='<%= MerchantID.Text %>'/>
  242. <input type="hidden" name="ReturnCustomerID" value='<%= CustomerID.Text %>'/>
  243. <input type="hidden" name="ReturnOrderTotal" value='<%= OrderTotal.Text %>'/>
  244. <input type="hidden" name="ReturnName" value='<%= Name.Text %>'/>
  245. <input type="hidden" name="ReturnAddress" value='<%= Address.Text %>'/>
  246. <input type="hidden" name="ReturnCity" value='<%= City.Text %>'/>
  247. <input type="hidden" name="ReturnState" value='<%= State.Text %>'/>
  248. <input type="hidden" name="ReturnZip" value='<%= Zip.Text %>'/>
  249. <input type="hidden" name="ReturnEmail" value='<%= Email.Text %>'/>
  250.  
  251. </form>
  252.  
  253. <% If SubmitForm = True Then %>
  254. <script type="text/javascript">
  255.   ReturnOrder.submit()
  256. </script>
  257. <% End If %>
  258.  
  259. </body>
  260. </html>
Aug 30 '08 #1
1 1459
omerbutt
638 512MB
when inserting recodrs into db
use sigle quotes around your double quotes WHEN CONCATINATING A VARIABLE in the values part
eg ' " & & " '
here watch this
Expand|Select|Wrap|Line Numbers
  1. field1_data="OMER"
  2. field2_data="ASLAM"
  3. field3_data="HELLO"
  4. sql="insert into table_name(field_1,field_2,field_3) values('"&field1_data&"','"&field2_data&"','"&field3_data&"');"
  5.  
Sep 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by windandwaves | last post: by
2 posts views Thread by Ian DeRock | last post: by
2 posts views Thread by Bobby | last post: by
2 posts views Thread by Themis Papassilekas | last post: by
2 posts views Thread by Vladislav Moltchanov | last post: by
5 posts views Thread by Steve Patrick | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.