[share] Insert Data Dengan ASP.NET dan MYSQL

Form Inputan


<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Odbc" %>

<%
Response.Write("<form action='program.aspx' method='post'>")
Response.Write("Masukan Nama Disini : <input type='TEXT' name='txtUsername'> ")
Response.Write("<input type='submit' value='Simpan'>")
Response.Write("</form>")
%>

Proses Data


<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Odbc" %>

<%
dim username
username = request.Form("txtUsername")
Dim objConn As OdbcConnection
Dim objCmd As OdbcCommand
Dim strSQL As String
Dim data As Integer = 0
objConn = New OdbcConnection("DRIVER={MYSQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=asp; UID=root; PASSWORD=12345; OPTION=3")
objConn.open()
strSQL="INSERT INTO user(username)VALUES('"& username &"')"
objCmd = New OdbcCommand(strSQL,objConn)
data = objCmd.ExecuteNonQuery()
if data = 1 THEN
Response.Write("Berhasil")
ELSE
Response.Write("Gagal")
END IF
objConn.Close

%>

Software bisa didownload disini
Panduan Instalasi dan configurasi bisa didownload disini

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: