techknow
04-18-04, 01:18 AM
100 MB Webspace free for a year to the first person that can tell me why this doesn't work and how to fix it so that it does work...
My hosting site is at http://atkhost.com if you would like more info about my services... (Not trying to spam here...)
Ok Here's the code, it's pretty simple;
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
Dim conlistings As OleDbConnection
Dim strInsert As String
Dim cmdInsert As OleDbCommand
conlistings = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=d:\websites\justoneguy.com\data\listings.md b" )
strInsert = "Insert Into Listings ( Address, City, Price, Bedrooms, Bathrooms, Views, Description, Comments ) Values ( @Address, @City, @Price, @Bedrooms, @Bathrooms, @Views, @Description, @Comments )"
cmdInsert = New OleDbCommand( strInsert, conlistings )
cmdInsert.Parameters.Add( "@Address", Address.Text )
cmdInsert.Parameters.Add( "@City", City.Text )
cmdInsert.Parameters.Add( "@Price", Price.Text )
cmdInsert.Parameters.Add( "@Bedrooms", Bedrooms.Text )
cmdInsert.Parameters.Add( "@Bathrooms", Bathrooms.Text )
cmdInsert.Parameters.Add( "@Views", Views.Text )
cmdInsert.Parameters.Add( "@Description", PropDescription.Text )
cmdInsert.Parameters.Add( "@Comments", Comments.Text )
conlistings.Open()
cmdINsert.ExecuteNonQuery()
conlistings.Close()
End Sub
</Script>
<html>
<head><title>FormInsert.aspx</title></head>
<body>
<form Runat="Server">
<h2>Add New Listing</h2>
<b>Address:</b>
<br>
<asp:TextBox
ID="Address"
Runat="Server" />
<p>
<b>City:</b>
<br>
<asp:TextBox
ID="City"
Runat="Server" />
<p>
<b>Price:</b>
<br>
<asp:TextBox
ID="Price"
Runat="Server" />
<p>
<b>Bedrooms:</b>
<br>
<asp:TextBox
ID="Bedrooms"
Runat="Server" />
<p>
<b>Bathrooms:</b>
<br>
<asp:TextBox
ID="Bathrooms"
Runat="Server" />
<p>
<b>Views:</b>
<br>
<asp:TextBox
ID="Views"
Runat="Server" />
<p>
<b>Description:</b>
<br>
<asp:TextBox
ID="Description"
Runat="server" Columns="3" />
<p>
<b>Comments:</b>
<br>
<asp:TextBox
ID="Comments"
Runat="Server" />
<p>
<asp:Button
Text="Add!"
OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>
My hosting site is at http://atkhost.com if you would like more info about my services... (Not trying to spam here...)
Ok Here's the code, it's pretty simple;
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
Dim conlistings As OleDbConnection
Dim strInsert As String
Dim cmdInsert As OleDbCommand
conlistings = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=d:\websites\justoneguy.com\data\listings.md b" )
strInsert = "Insert Into Listings ( Address, City, Price, Bedrooms, Bathrooms, Views, Description, Comments ) Values ( @Address, @City, @Price, @Bedrooms, @Bathrooms, @Views, @Description, @Comments )"
cmdInsert = New OleDbCommand( strInsert, conlistings )
cmdInsert.Parameters.Add( "@Address", Address.Text )
cmdInsert.Parameters.Add( "@City", City.Text )
cmdInsert.Parameters.Add( "@Price", Price.Text )
cmdInsert.Parameters.Add( "@Bedrooms", Bedrooms.Text )
cmdInsert.Parameters.Add( "@Bathrooms", Bathrooms.Text )
cmdInsert.Parameters.Add( "@Views", Views.Text )
cmdInsert.Parameters.Add( "@Description", PropDescription.Text )
cmdInsert.Parameters.Add( "@Comments", Comments.Text )
conlistings.Open()
cmdINsert.ExecuteNonQuery()
conlistings.Close()
End Sub
</Script>
<html>
<head><title>FormInsert.aspx</title></head>
<body>
<form Runat="Server">
<h2>Add New Listing</h2>
<b>Address:</b>
<br>
<asp:TextBox
ID="Address"
Runat="Server" />
<p>
<b>City:</b>
<br>
<asp:TextBox
ID="City"
Runat="Server" />
<p>
<b>Price:</b>
<br>
<asp:TextBox
ID="Price"
Runat="Server" />
<p>
<b>Bedrooms:</b>
<br>
<asp:TextBox
ID="Bedrooms"
Runat="Server" />
<p>
<b>Bathrooms:</b>
<br>
<asp:TextBox
ID="Bathrooms"
Runat="Server" />
<p>
<b>Views:</b>
<br>
<asp:TextBox
ID="Views"
Runat="Server" />
<p>
<b>Description:</b>
<br>
<asp:TextBox
ID="Description"
Runat="server" Columns="3" />
<p>
<b>Comments:</b>
<br>
<asp:TextBox
ID="Comments"
Runat="Server" />
<p>
<asp:Button
Text="Add!"
OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>