|
-
Feb 11th, 2005, 01:35 AM
#1
Thread Starter
Hyperactive Member
Will someone proofread this for me?
I am new to asp.net and want to start off on the right foot... Now the code works properly.. and it does add the data to the database which for all intentions is all I need... But being self taught I want to make sure I did this properly...
So will someone proof this for me and see if I am headed in the right direction? Basically I just want to make sure I am adding data using the correct technique!
Also I wanted to use a dropdown box for the state field but I kept getting and error saying I could not use .Text ... So I converted it to a Textfield for now... what do I use please?
Thanks!!
Code:
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.sqlclient" %>
<script runat="server">
Sub Button_Click( s as object, e as eventargs )
dim myConnection as SqlConnection
dim strInsert as string
dim cmdInsert as SqlCommand
myConnection = new sqlconnection( "server=localhost;uid=myid;pwd=mypassword;database=store" )
strInsert = "insert t_manufacturer (manufacturer_name, manufacturer_address1, manufacturer_address2, manufacturer_city, manufacturer_state, manufacturer_zip, manufacturer_country, manufacturer_account, manufacturer_url, manufacturer_primary_contact, manufacturer_primary_telephone, manufacturer_primary_telephone_ext, manufacturer_primary_email ) values ( @txtManufacturerName, @txtAddress1, @txtAddress2, @txtCity, @txtState, @txtZip, @txtCountry, @txtAccount, @txtManufacturerURL, @txtPrimaryContact, @txtPrimaryContactPhone, @txtPrimaryContactExt, @txtPrimaryContactEmail )"
cmdInsert = New SqlCommand( strInsert, myConnection )
cmdInsert.Parameters.Add("@txtManufacturerName", txtManufacturerName.Text )
cmdInsert.Parameters.Add("@txtAddress1", txtAddress1.Text )
cmdInsert.Parameters.Add("@txtAddress2", txtAddress2.Text )
cmdInsert.Parameters.Add("@txtCity", txtCity.Text )
cmdInsert.Parameters.Add("@txtState", txtState.Text )
cmdInsert.Parameters.Add("@txtZip", txtZip.Text )
cmdInsert.Parameters.Add("@txtCountry", txtCountry.Text )
cmdInsert.Parameters.Add("@txtAccount", txtAccount.Text )
cmdInsert.Parameters.Add("@txtManufacturerURL", txtManufacturerURL.Text )
cmdInsert.Parameters.Add("@txtPrimaryContact", txtPrimaryContact.Text )
cmdInsert.Parameters.Add("@txtPrimaryContactPhone", txtPrimaryContactPhone.Text )
cmdInsert.Parameters.Add("@txtPrimaryContactExt", txtPrimaryContactExt.Text )
cmdInsert.Parameters.Add("@txtPrimaryContactEmail", txtPrimaryContactEmail.Text )
myConnection.open()
cmdInsert.ExecuteNonQuery()
myConnection.Close()
lblStatus.Text = txtManufacturerName.Text + " has been added succesfully!"
End Sub
</script>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Create New Manufacturer</title>
</head>
<body>
<form runat="server">
<div align="center">
<center>
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="778" id="AutoNumber1" height="0">
<tr>
<td width="100%">
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2" height="0">
<tr>
<td width="100%"><b><font face="Verdana" size="2">Create New
Manufacturer:
<asp:Label ForeColor="#FF0000" ID="lblStatus" runat="server" />
</font></b></td>
</tr>
<tr>
<td width="100%"><font face="Verdana" size="1">Please complete the
following information to add a new manufacturer.</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%">
<table width="75%" border="0" cellpadding="2" bordercolor="#111111" id="AutoNumber3" style="border-collapse: collapse">
<tr>
<td width="30%"><b><font face="Verdana" size="1">Manufacturer Name:</font></b></td>
<td width="70%">
<asp:TextBox Columns="28" Font-Name="Verdana" Font-Size="8" ID="txtManufacturerName" MaxLength="80" runat="server" TextMode="SingleLine" ToolTip="Manufacturer's Name" TabIndex="1" />
<b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Address (1):</font></b></td>
<td width="71%">
<asp:TextBox ID="txtAddress1" ToolTip="Manufacturer's Address Line 1" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="2" />
<b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Address (2):</font></b></td>
<td width="71%">
<asp:TextBox ID="txtAddress2" ToolTip="Manufacturer's Address Line 2" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="3" /></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">City:</font></b></td>
<td width="71%">
<asp:TextBox ID="txtCity" ToolTip="Manufacturer's City" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="4" />
<b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">State:</font></b></td>
<td width="71%">
<b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">
<asp:TextBox ID="txtState" ToolTip="Manufacturer's City" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="5" />
*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Zip Code:</font></b></td>
<td width="71%"><font size="1">
<asp:TextBox ID="txtZip" ToolTip="Manufacturer's Zip Code" TextMode="SingleLine" runat="server" Columns="10" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="6" />
</font><b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Country:</font></b></td>
<td width="71%"> <b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">
<asp:TextBox ID="txtCountry" ToolTip="Manufacturer's City" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="7" />
*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Account #:</font></b></td>
<td width="71%">
<asp:TextBox ID="txtAccount" ToolTip="Your Account # for Manufacturer" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="8" />
<b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Manufacturer URL:</font></b></td>
<td width="71%">
<asp:TextBox ID="txtManufacturerURL" ToolTip="Web Address of Manufacturer" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="9" /></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Primary Contact:</font></b></td>
<td width="71%">
<asp:TextBox ID="txtPrimaryContact" ToolTip="Contact's Name" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="10" /></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Primary Contact
Telephone:</font></b></td>
<td width="71%"><font size="1">
<asp:TextBox ID="txtPrimaryContactPhone" ToolTip="Contact's Telephone Number" TextMode="SingleLine" runat="server" Columns="14" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="11" />
</font><b><font face="Verdana" size="1" color="#FF0000"><span class="redhighlight_text">*</span></font></b><font size="1"><font face="Verdana">
Ext: </font>
<asp:TextBox ID="txtPrimaryContactExt" ToolTip="Contact's Telephone Number Extension" TextMode="SingleLine" runat="server" Columns="5" Font-Name="Verdana" Font-Size="8" MaxLength="5" TabIndex="12" />
</font></td>
</tr>
<tr>
<td width="29%"><b><font face="Verdana" size="1">Primary Contact
Email:</font></b></td>
<td width="71%">
<asp:TextBox ID="txtPrimaryContactEmail" ToolTip="Contact's Email" TextMode="SingleLine" runat="server" Columns="28" Font-Name="Verdana" Font-Size="8" MaxLength="80" TabIndex="13" /></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button Font-Name="Verdana" Font-Names="Verdana" Font-Size="8" ID="btnSubmit" runat="server" OnClick = "Button_Click" Text="Add Manufacturer" ToolTip="Add Manufacturer" TabIndex="14" Width="110" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
Last edited by Anjari; Feb 11th, 2005 at 01:46 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|