473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't insert data to ms access

1 New Member
dear all,
please help me that my script cannot insert data to ms acces.

<%@ Page Language="vb" ContentType="te xt/html"%>
<%@ Import NameSpace = "System.Dat a" %>
<%@ Import NameSpace = "System.Data.Ol eDb" %>

<script runat="server">

Sub Insert_Btn (s As Object, e As EventArgs)
Dim Conn As OleDbConnection
Dim ConnCommand As OleDbCommand
Dim ConnString, InsertString As String
Dim batas_peminjama n As Integer
Dim InputNama_depan , InputNama_tenga h, InputNama_belak ang, InputNama_total As String

ConnString = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA SOURCE=D:\Inetp ub\wwwroot\Prak \perpustakaan.m db"

Conn = New OleDbConnection (ConnString)
Conn.Open()

InputNama_depan = (txtnamadepan.T ext)
InputNama_tenga h = (txtnamatengah. Text)
InputNama_belak ang = (txtnamabelakan g.Text)
InputNama_total = ((InputNama_dep an) + (InputNama_teng ah) + (InputNama_bela kang))

select case DropDownJenis.S electedItem.Tex t
case "Dosen": batas_peminjama n = 30
case "MHS_IT": batas_peminjama n = 14
case "Non_IT": batas_peminjama n = 7
case else : batas_peminjama n = 5
end select

InsertString = " INSERT INTO pinjam (no_anggota, nama_anggota, alamat_anggota, email_anggota, fakjur, jenis_anggota, batas_peminjama n) VALUES ('" & txtno.Text & "', '" & InputNama_Total & "', '" & txtALAMAT.Text & "', '" & txtemail.Text & "', " & DropDownFakjur. SelectedItem.Te xt & ", '" & DropDownJenis.S electedItem.Tex t & "', '" & batas_peminjama n & "')"

ConnCommand = New OleDbCommand (InsertString,C onn)

Conn.Close()
End Sub

</script>

<html>
<head>
<title>Insert Data </title>
<style type="text/css">
<!--
.style1 {
font-family: "Comic Sans MS";
font-weight: bold;
}
-->
</style>
</head>
<body>
<form runat="server">
<table width="100%" height="222" border="0" class="style1">
<tr>
<td width="164" height="26">No Anggota</td>
<td width="86"><div align="center"> <strong>:</strong></div></td>
<td width="711">
<asp:TextBox ID="txtno" MaxLength="7" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatorno " ControlToValida te="txtno" ErrorMessage="N o Anggota harus di ISI" Display="Static " runat="server"/>
<asp:RegularExp ressionValidato r ID="Regularno" ControlToValida te="txtno" ValidationExpre ssion="\d{7}" ErrorMessage="N omer anggota harus tujuh DIGIT" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a Depan </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamadepa n" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatorna madepan" ControlToValida te="txtnamadepa n" ErrorMessage="N AMA DEPAN harus di ISI" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a tengah </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamateng ah" CssClass="style 1" runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a Belakang </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamabela kang" CssClass="style 1" runat="server"/>
</td>
</tr>
<tr>
<td height="26">Ala mat Anggota </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtalamat" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatoral amat" ControlToValida te="txtalamat" ErrorMessage="A LAMAT harus di ISI" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Ema il Anggota </td>
<td><div align="center"> <strong>:</strong></div></td>
<td><asp:TextBo x ID="txtemail" CssClass="style 1" runat="server"/></td>
</tr>

<tr>
<td height="24">Fak jur</td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:DropDownLi st ID="DropDownFak jur" CssClass="style 1" runat="server">
<asp:ListItem Value="sastra_i nggris">FS-S1 sastra Inggris</asp:ListItem>
<asp:ListItem Value="sastra_J epang">FS-S1 sastra Jepang</asp:ListItem>
<asp:ListItem Value="D3_sastr a_inggris">FS-D3 sastra Inggris</asp:ListItem>
<asp:ListItem Value="d3_sastr a_mandarin">FS-D3 sastra mandarin</asp:ListItem>
</asp:DropDownLis t>
</td>
</tr>
<tr>
<td height="24">Gol ongan</td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:DropDownLi st ID="DropDownJen is" CssClass="style 1" runat="server">
<asp:ListItem Value="dosen">D osen</asp:ListItem>
<asp:ListItem Value="it">Maha siswa IT</asp:ListItem>
<asp:ListItem Value="non_it"> Mahasiswa Non IT</asp:ListItem>
<asp:ListItem Value="luar">Ma hasiswa Luar</asp:ListItem>
</asp:DropDownLis t>
</td>
</tr>

<tr>
<td height="52" colspan="3">
<asp:Button Text="Insert-Data" OnClick="Insert _Btn" runat="server"/>
<asp:Label ID="txtResult" runat="server" ForeColor="#009 999"/></td>
</tr>
</table>
<hr color="#009999" >
<hr color="#009999" >
</form>
</body>
</html>
Apr 4 '07 #1
1 1837
dip_developer
648 Recognized Expert Contributor
dear all,
please help me that my script cannot insert data to ms acces.

<%@ Page Language="vb" ContentType="te xt/html"%>
<%@ Import NameSpace = "System.Dat a" %>
<%@ Import NameSpace = "System.Data.Ol eDb" %>

<script runat="server">

Sub Insert_Btn (s As Object, e As EventArgs)
Dim Conn As OleDbConnection
Dim ConnCommand As OleDbCommand
Dim ConnString, InsertString As String
Dim batas_peminjama n As Integer
Dim InputNama_depan , InputNama_tenga h, InputNama_belak ang, InputNama_total As String

ConnString = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA SOURCE=D:\Inetp ub\wwwroot\Prak \perpustakaan.m db"

Conn = New OleDbConnection (ConnString)
Conn.Open()

InputNama_depan = (txtnamadepan.T ext)
InputNama_tenga h = (txtnamatengah. Text)
InputNama_belak ang = (txtnamabelakan g.Text)
InputNama_total = ((InputNama_dep an) + (InputNama_teng ah) + (InputNama_bela kang))

select case DropDownJenis.S electedItem.Tex t
case "Dosen": batas_peminjama n = 30
case "MHS_IT": batas_peminjama n = 14
case "Non_IT": batas_peminjama n = 7
case else : batas_peminjama n = 5
end select

InsertString = " INSERT INTO pinjam (no_anggota, nama_anggota, alamat_anggota, email_anggota, fakjur, jenis_anggota, batas_peminjama n) VALUES ('" & txtno.Text & "', '" & InputNama_Total & "', '" & txtALAMAT.Text & "', '" & txtemail.Text & "', " & DropDownFakjur. SelectedItem.Te xt & ", '" & DropDownJenis.S electedItem.Tex t & "', '" & batas_peminjama n & "')"

ConnCommand = New OleDbCommand (InsertString,C onn)

Conn.Close()
End Sub

</script>

<html>
<head>
<title>Insert Data </title>
<style type="text/css">
<!--
.style1 {
font-family: "Comic Sans MS";
font-weight: bold;
}
-->
</style>
</head>
<body>
<form runat="server">
<table width="100%" height="222" border="0" class="style1">
<tr>
<td width="164" height="26">No Anggota</td>
<td width="86"><div align="center"> <strong>:</strong></div></td>
<td width="711">
<asp:TextBox ID="txtno" MaxLength="7" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatorno " ControlToValida te="txtno" ErrorMessage="N o Anggota harus di ISI" Display="Static " runat="server"/>
<asp:RegularExp ressionValidato r ID="Regularno" ControlToValida te="txtno" ValidationExpre ssion="\d{7}" ErrorMessage="N omer anggota harus tujuh DIGIT" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a Depan </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamadepa n" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatorna madepan" ControlToValida te="txtnamadepa n" ErrorMessage="N AMA DEPAN harus di ISI" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a tengah </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamateng ah" CssClass="style 1" runat="server"/>
</td>
</tr>
<tr>
<td height="26">Nam a Belakang </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtnamabela kang" CssClass="style 1" runat="server"/>
</td>
</tr>
<tr>
<td height="26">Ala mat Anggota </td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:TextBox ID="txtalamat" CssClass="style 1" runat="server"/>
<asp:RequiredFi eldValidator ID="Validatoral amat" ControlToValida te="txtalamat" ErrorMessage="A LAMAT harus di ISI" Display="Static " runat="server"/>
</td>
</tr>
<tr>
<td height="26">Ema il Anggota </td>
<td><div align="center"> <strong>:</strong></div></td>
<td><asp:TextBo x ID="txtemail" CssClass="style 1" runat="server"/></td>
</tr>

<tr>
<td height="24">Fak jur</td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:DropDownLi st ID="DropDownFak jur" CssClass="style 1" runat="server">
<asp:ListItem Value="sastra_i nggris">FS-S1 sastra Inggris</asp:ListItem>
<asp:ListItem Value="sastra_J epang">FS-S1 sastra Jepang</asp:ListItem>
<asp:ListItem Value="D3_sastr a_inggris">FS-D3 sastra Inggris</asp:ListItem>
<asp:ListItem Value="d3_sastr a_mandarin">FS-D3 sastra mandarin</asp:ListItem>
</asp:DropDownLis t>
</td>
</tr>
<tr>
<td height="24">Gol ongan</td>
<td><div align="center"> <strong>:</strong></div></td>
<td>
<asp:DropDownLi st ID="DropDownJen is" CssClass="style 1" runat="server">
<asp:ListItem Value="dosen">D osen</asp:ListItem>
<asp:ListItem Value="it">Maha siswa IT</asp:ListItem>
<asp:ListItem Value="non_it"> Mahasiswa Non IT</asp:ListItem>
<asp:ListItem Value="luar">Ma hasiswa Luar</asp:ListItem>
</asp:DropDownLis t>
</td>
</tr>

<tr>
<td height="52" colspan="3">
<asp:Button Text="Insert-Data" OnClick="Insert _Btn" runat="server"/>
<asp:Label ID="txtResult" runat="server" ForeColor="#009 999"/></td>
</tr>
</table>
<hr color="#009999" >
<hr color="#009999" >
</form>
</body>
</html>



i think its a silly mistake ...
Where is the code for execution of your command object.
Put ConnCommand .ExecuteNonQuer y()
Apr 4 '07 #2

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

Similar topics

1
1923
by: jason | last post by:
If one is attempting to insert data into tables at the same time what is the best way to do this. I could do it the way below - but is there any reason I should not do it this way or perhaps follow a better route. The second table is really an audit table to track changes made by the user Set cnn = CreateObject("ADODB.Connection") strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../database/listings.mdb") ...
5
9096
by: Ervs Sevilla via SQLMonster.com | last post by:
BCP and Bulk Insert to Linked Servers Hi guys! Heres my set up: 1) Im using Win2003 with MS SQL 2000 2) I have a linked server in SQL Server pointing to an MS Access DB. Why MS Access? Gee, I dont know. The guy who owns it refused to update his
0
4487
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored procedure from SQL Server vs MS Access point of view ?
1
2919
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
7
6659
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks!
3
3441
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
2
3195
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request : INSERT INTO temp_tab VALUES (1,2,3)
3
6729
by: brianbasquille | last post by:
Hello all, Strange little problem here... am just trying to insert some basic information into an Access Database using OleDB. I'm getting a "Syntax error in Insert Into statement" when it tries to execute the SQL. The strange thing is if i take the exact SQL being executed from the debugger and insert and execute it using the MS Access query engine, it works fine!
5
4584
by: djsdaddy | last post by:
Good Day All, I have some EEO data in an old dBase4 database that I have converted to an Access table. Since dBase was not a relational database, I didn't create any key fields. I linked all of the tables together on Employees' SSN; therefore, in order to use this data with the current Access database, I need to create a relationship between the old dBase4 EEO data and the Access employee data. The Access employee data was also an old dBase...
1
3550
by: Jim | last post by:
I'm trying to take the data from strSQL below and "append / insert" that into the Access database. The problem is: although the listbox displays correctly, the Access table gets the first record inserted to the table multiple times - as many rows as there are in the source table. Obviously the Access parameters aren't getting updated properly. I've tried putting the .parameters.Add outside the for - next loop. No joy. Also, if...
0
8315
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.