Hi all,
I tried to do N-Tier application.
My Question is:
How to send textbox value to DAL when click the submit-button ?
( i understand that i need to have a business layer to validate and from there i have to pass the values to DAL)
i need to know how to pass the parameter values to DAL from PL through Business layer
Can any one help me to get an idea - please? As in Presentation Layer - i just created the form but not coding:
<div style="border:solid 1px gray; width:500px; height:400px">
<table>
<tr><td>Customer Name</td><td><asp:TextBox ID="txtcstnm" runat="server"></asp:TextBox></td></tr>
<tr><td>Customer City</td><td><asp:TextBox ID="txtcstcity" runat="server"></asp:TextBox></td></tr>
<tr><td></td><td><asp:Button ID="btncreatecustomer" runat="server" Text="Create" /></td></tr>
</table>
</div>
coding of DAL is:
Imports System.Data
Imports MySql.Data.MySqlClient
Namespace InvDataLayer
Public MustInherit Class mysqlconn_sampledb
Public dbconn As MySqlConnection = New MySqlConnection("Server=localhost; database=sampledb; userid=root; password=xxxxx; port=3307;")
End Class
End Namespace
Public Class invoiceDAL
Inherits InvDataLayer.mysqlconn_sampledb
Public Function clsInsertCustomer(ByVal objDB As InvDataLayer.mysqlconn_sampledb)
Try
Dim cmd As MySqlCommand
Dim c1 As MySqlConnection
c1 = objDB.dbconn
c1.Open()
cmd = New MySqlCommand("sp_insertcustomer", c1)
'cmd.Parameters.Add("p_cstnm")
cmd.CommandType = CommandType.StoredProcedure
cmd.ExecuteNonQuery()
c1.Close()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error found")
End Try
Return Nothing
End Function
End Class
Stored Procedure is:
DELIMITER $$
DROP PROCEDURE IF EXISTS `sampledb`.`sp_insertcustomer` $$
CREATE PROCEDURE `sampledb`.`sp_insertcustomer`
(
IN p_cstnm varchar(100),
IN p_cstcity varchar(50)
)
BEGIN
INSERT INTO tblcustomer
(cstnm,cstcity) VALUES(p_cstnm,p_cstcity);
END $$
DELIMITER ;