codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  asp.net n access database  ling_luv at 02:14 on Wednesday, June 13, 2007
 

hi, i am new to asp.net. i currently need to do a website. i have created a Add form.In this Add form when the user key in the record n press the submit button the record will be added into the access database "dvd_rental". in the database there are 3 table actor, director n movie the record need to be added into the respective table. i hav problem in adding into the table. below is my coding is my connection wrong? thanks 4 the help.

<script runat="server">

Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Moviename
Dim Actorname
Dim Director
Dim Language
Dim Numberofdisc
Dim Studio
Dim ReleaseDate
Dim Price
Dim Quantity
Dim sql
'Dim conn



Moviename = Request.Form("Moviename")
Actorname = Request.Form("Actorname")
Director = Request.Form("Director")
Language = Request.Form("Language")
Numberofdisc = Request.Form("Numberofdisc")
Studio = Request.Form("Studio")
ReleaseDate = Request.Form("ReleaseDate")
Price = Request.Form("Price")
Quantity = Request.Form("Quantity")

'Dim DBconn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("dvd_rental.mdb"))


'DBconn.Open()

'Dim cmd As New OleDb.OleDbCommand


'Dim dbsql As New OleDb.OleDbCommand


'Dim ConnString As String = ("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("dvd_rental.mdb"))
'Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(ConnString)
'Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql)
'DBconn.Open()

'sql.ExecuteNonQuery()
'Dim connString As String = "server='localhost'; trusted_connection=true; database='dvd_rental'"
Dim DBconn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("dvd_rental.mdb"))
Dim sqlconn As System.Data.OleDb.OleDbConnection = DBconn
DBconn.Open()
Sql = "insert into movie (Moviename, Language, Numberofdisc, Studio, ReleaseDate, Price, Quantity) "

sql = sql & " values ('" & Moviename & "' "
sql = sql & ",'" & Language & "'"
sql = sql & ",'" & Numberofdisc & "'"
sql = sql & ",'" & Studio & "'"
sql = sql & ",'" & ReleaseDate & "'"
sql = sql & ",'" & Price & "'"
sql = sql & ",'" & Quantity & "')"

Dim sqlcmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(sql, sqlconn)





'sql = "insert into movie (Moviename, Language, Numberofdisc, Studio, ReleaseDate, Price, Quantity) "

'sql = sql & " values ('" & Moviename & "' "
'sql = sql & ",'" & Language & "'"
'sql = sql & ",'" & Numberofdisc & "'"
'sql = sql & ",'" & Studio & "'"
'sql = sql & ",'" & ReleaseDate & "'"
'sql = sql & ",'" & Price & "'"
'sql = sql & ",'" & Quantity & "')"



DBconn.Close()
DBconn = Nothing

Response.Redirect("/forum/WebAddResult.html")
End Sub
</script>

<HTML>
<HEAD>

<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>WebAdd.aspx</title>
</HEAD>
<script language="javascript" type="text/javascript">

function Table1_onclick() {

}

function Text1_onclick() {

}

</script>

<body bgcolor="#cccc99">
<form action="/forum/WebAdd.html" method="post" runat="server">
<P>
<Table id="Table1" cellSpacing="1" cellPadding="1" border="1" onClick="return Table1_onclick()" style="width: 532px; height: 404px">
<TR>
<TD style="width: 237px">
<asp:Label id="AddNewDvd" runat="server" Width="240px" DESIGNTIMEDRAGDROP="8" Font-Bold="True" Font-Size="14pt" Font-Names="Times New Roman">Add new DVD Record</asp:Label></TD>
<TD style="width: 284px"></TD>
</TR>
<TR>
<TD style="height: 23px; width: 237px;"></TD>
<TD style="height: 23px; width: 284px;"></TD>
</TR>
<TR>
<TD style="width: 237px">
<asp:Label id="Moviename" runat="server" Width="112px" Font-Size="14pt">DVD Title:</asp:Label></TD>
<TD style="width: 284px">
<asp:TextBox ID="txtmovieName" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="width: 237px">
<asp:Label id="Actor" runat="server" Width="112px" Font-Size="14pt">Actor:</asp:Label></TD>
<TD style="width: 284px">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource1"
DataTextField="Actor_Name" DataValueField="Actor_Name" Width="132px">
</asp:DropDownList><asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/dvd_rental.mdb"
SelectCommand="SELECT [Actor Name] AS Actor_Name FROM [Actor]"></asp:AccessDataSource>
<br />
<asp:TextBox ID="txtActorname" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="width: 237px; height: 32px;">
<asp:Label id="Director" runat="server" Width="112px" Font-Size="14pt">Director:</asp:Label></TD>
<TD style="width: 284px; height: 32px">
<br />
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="AccessDataSource2"
DataTextField="Director_Name" DataValueField="Director_Name">
</asp:DropDownList><asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/dvd_rental.mdb"
SelectCommand="SELECT [Director Name] AS Director_Name FROM [Director]"></asp:AccessDataSource>
<asp:TextBox ID="txtDirector" runat="server"></asp:TextBox></TD>
</TR>
<tr>
<td style="width: 237px; height: 32px">
<asp:Label ID="language" runat="server" Font-Size="14pt" Width="112px">Language:</asp:Label></td>
<td style="width: 284px; height: 32px">
<asp:TextBox ID="txtlanguage" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 237px; height: 32px">
<asp:Label ID="Numberofdisc" runat="server" Font-Size="14pt" Width="145px">Number of Disc:</asp:Label></td>
<td style="width: 284px; height: 32px">
<asp:TextBox ID="txtNoofDisc" runat="server"></asp:TextBox></td>
</tr>
<TR>
<TD style="width: 237px; height: 32px;">
<asp:Label id="Studio" runat="server" Width="112px" Font-Size="14pt">Studio:</asp:Label></TD>
<TD style="height: 32px; width: 284px;">
<asp:TextBox ID="txtStudio" runat="server"></asp:TextBox></TD>
</TR>
<tr>
<td style="width: 237px">
<asp:Label ID="ReleaseDate" runat="server" Font-Size="14pt" Width="112px">Release Date:</asp:Label></td>
<td style="width: 284px">
<asp:TextBox ID="txtReleaseDate" runat="server"></asp:TextBox></td>
</tr>
<TR>
<TD style="width: 237px">
<asp:Label id="Price" runat="server" Width="112px" Font-Size="14pt">Price:</asp:Label></TD>
<TD style="width: 284px">
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="HEIGHT: 11px; width: 237px;">
<asp:Label id="Quantity" runat="server" Width="112px" Font-Size="14pt">Quantity:</asp:Label></TD>
<TD style="HEIGHT: 11px; width: 284px;">
<asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="width: 237px"></TD>
<TD style="width: 284px"></TD>
</TR>
<TR>
<TD style="HEIGHT: 3px; width: 237px;">
<asp:Button ID="Submit" runat="server" Text="Submit" OnClick="Submit_Click" /></TD>

<TD style="HEIGHT: 3px; width: 284px;"></TD>
</TR>
</TABLE>
</P>
<P> </P>
</form>
</body>
</HTML>









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Passing parameters to a perl program from a HTML form
•  calling javascript function in asp page
•  Calculation error in Javascript
•  help try to update parameters in sql server with Stored Procedure in ASP
•  help try to update parameters in sql server with Stored Procedure in ASP
•  help try to update parameters in sql server with Stored Procedure in ASP
•  Re: Can anyone please help me, html table to access.
•  Get strings between tags on web pages
•  Providing time parameters to user when searching


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007