I am trying to insert data into a access database when the user clicks a submit button but i get the error:
Format of the initialization string does not conform to specification starting at index 0.
This is my code:
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script runat=server>
sub conecter (ByVal sender As Object, ByVal e As EventArgs)
Dim cmd As New OleDbCommand("INSERT INTO email (email)VALUES('" & TextBox.Text & "')", New OleDbConnection("C:\Documents and Settings\Loowee\My Documents\emails.mdb"))
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Sub
</script>
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="text-decoration: underline">Quailty mailer v.1<br />
<br />
Subscribe:</span> Ener E-mail here: <asp:TextBox ID="TextBox" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Submit" Onclick="conecter"/></div>
</form>
</body>
</html>
Can someone please help.