473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

asp.net n access database

hi, i am new to asp.net. i currently doin a website. i created a add form in this form the user need to add in the record n when they press the submit button it will add the record into the access database "dvd_rental" in the respective table in actor, director, movie. in the form for the actor n director there is a dropdown list for user to choose, if the actor or director is not in the dropdown list they need to key in the name. May i noe wat code should i use n how am i goin to populate the dropdown list from the access database? below is the code that i have done so far. thanks in advance for helping.

<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 asql


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

DBconn.Open()


Moviename = Request.Form("txtmovieName")
Actorname = Request.Form("txtActorname")
Director = Request.Form("txtDirector")
Language = Request.Form("txtLanguage")
Numberofdisc = Request.Form("txtNoofdisc")
Studio = Request.Form("txtStudio")
ReleaseDate = Request.Form("txtReleaseDate")
Price = Request.Form("txtPrice")
Quantity = Request.Form("txtQuantity")


sql = "INSERT INTO Movie(MovieName, MovieLanguage, 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 & "')"


'asql = "INSERT INTO Actor(Actor Name)VALUES('" & Actorname & "')"

'Dim dbq As New OleDb.OleDbCommand
'dbq.CommandType = CommandType.Text
'dbq.CommandText = asql
'dbq.Connection = DBconn
'dbq.ExecuteNonQuery()



Dim dbquery As New OleDb.OleDbCommand
dbquery.CommandType = CommandType.Text
dbquery.CommandText = sql
dbquery.Connection = DBconn
dbquery.ExecuteNonQuery()


DBconn.Close()
DBconn = Nothing


Response.Redirect("WebAddResult.aspx")

End Sub


Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)



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="WebAdd.aspx" 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" Width="132px" EnableTheming="True" OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged" >
<asp:ListItem></asp:ListItem>
</asp:DropDownList>&nbsp;
<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">
<asp:DropDownList ID="DropDownList2" runat="server" Width="138px">
</asp:DropDownList><br />
<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; height: 28px;">
<asp:Label ID="ReleaseDate" runat="server" Font-Size="14pt" Width="112px">Release Date:</asp:Label></td>
<td style="width: 284px; height: 28px;">
<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" /></TD>

<TD style="HEIGHT: 3px; width: 284px;"></TD>
</TR>
</TABLE>
</P>
<P>&nbsp;</P>
</form>
</body>
</HTML>
Jun 13 '07 #1
1 1454
kenobewan
4,871 Expert 4TB
Is this script working? You can populate the control in the page load by connecting to the db, filling a dataset with the datareader and then binding the dataset to the control. HTH.
Jun 13 '07 #2

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

Similar topics

3
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
49
by: Mell via AccessMonster.com | last post by:
I created databases on Access 2003 and I want to deploy them to users. My code was also done using 2003. If they have Ms Access 2000 or higher, will they be able to use these dbs with all code,...
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
34
by: Mathieu Trentesaux | last post by:
Hello I downloaded Office 2007 for this reason : It seems, once again, that it is impossible to save any modification done in a VBA library, from the main project in Access. The save button...
21
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a...
11
by: Harel | last post by:
I have a report SQL which have been working for a few weeks. Its large and the target database is large. It has 59 join, and I dont think there is anything I can do about this, since the DB I use...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.