Mar 1, 2007
Hello Coders,
I need help fixing a problem in my code that I do not understand. I basically have a procedure that is supposed to take all user information and then insert it to the DB or update the Database based on user entry.
The call to the method is this
Dim bankname As String = ""
If (objBill.BillTransaction(Session("conString"), Session("whattobill"), PROC_CURR, Session("lISN"), 0, Session("fISN"), Request.ServerVariables("REMOTE_ADDR"), "scott@mycleanstart.com", Session("fAmount"), Session("first_name"), Session("last_name"), Session("city"), Session("state"), Session("phone"), Session("address1"), Session("address2"), Session("postal_code"), Session("email_address"), Session("fDesc"), Session("ssn"), Session("nameoncard"), Session("PAN"), Session("cvv"), Session("cardexpirationdate"), bankname, Session("txtroutingnumber"), Session("txtaccountnumber"), Session("txtchecknumber"), Session("bqISN"), _
returnedbqISN, AuthCode, OrderNumber, DeclineCode, TermCode, ErrorMessage, authenticationValue, authenticationTransactionID, str_Centinal_ECI, "signup", PAResStatus, SignatureVerification, paypalSubAgreeID, notificationLocation, strErrorNo, strErrorDesc, strTransactionID, strStatus, strStatusCode, strReasonCode)) Then
And then below is the actual method itself........
NOTE: The code below is contained in a DLL
1 public bool BillTransaction(string strDBInstance, string ccORach, string whichProcessor,Int32 lISN, Int32 mISN,
2 Int32 fISN, string ip,string merchant_email,string total_amount,
3 string firstname, string lastname, string city,string state, string phone, string address1,string address2, string zip, string customer_email,
4 string product_desc, string socialsecuritynum, string nameoncard, string creditcardnumber, Int32 cardverifynum, DateTime cardexpiredate,
5 string bankname, string routingnumber, string accountnumber, string checknumber, Int32 bqISN,
6 ref Int32 returnedbqISN, ref string AuthCode, ref string OrderNumber, ref string DeclineCode,
7 ref string TermCode, ref string ErrorMessage,
8 string authenticationValue,string authenticationTransactionID,string eci,string transactiontype,
9 string PAResStatus, string SignatureVerification, string paypalSubAgreeID, string notificationLocation,
10 ref string strErrorNo, ref string strErrorDesc, ref string strTransactionId, ref string strStatus,
11 ref string strStatusCode, ref string strReasonCode)
12
13 {
14
15 if (ccORach.Trim().Length <= 0)
16 {
17 ErrorMessage = "CC or Check?";
18 return false;
19 }
20
21 if (whichProcessor.Trim().Length <= 0)
22 {
23 ErrorMessage = "Blank processor";
24 return false;
25 }
26
27 decimal grand_total = Convert.ToDecimal(decimal.Parse(total_amount).ToString("N2"));
28 string ProcessorResponse="";
29 Database db = DatabaseFactory.CreateDatabase(strDBInstance);
30 DBCommandWrapper dbCmdWrapper = null;
31 bool retBilling = true;
32 string sql = "";
33 string bqAction = "SBILL";
34 string strFirstName = "";
35 string strLastName = "";
36 string[] cardname = nameoncard.Split(new char[] {' '});
37 strFirstName = cardname[0];
38 for (int i=1; i <= cardname.GetUpperBound(0); i++)
39 {
40 strLastName = strLastName + ' ' + cardname[i].Trim();
41 }
42
43 MCS_Encryption.Encryption mcscrypt = new MCS_Encryption.Encryption();
44 //card number
45 string enc_cardnumber = mcscrypt.Encrypt(creditcardnumber);
46 //account number
47 string enc_accountnumber = mcscrypt.Encrypt(accountnumber);
48
49 if (bqISN > 0)
50 {
51 //if bqISN is present, do UPDATE instead
52 sql = "spUpdateBillingQ";
53 dbCmdWrapper = db.GetStoredProcCommandWrapper(sql);
54 dbCmdWrapper.AddInParameter("@bqISN",DbType.Int32,bqISN);
55 dbCmdWrapper.AddInParameter("@email",DbType.String,customer_email);
56 dbCmdWrapper.AddInParameter("@bankname",DbType.String,bankname);
57 dbCmdWrapper.AddInParameter("@routingnumber",DbType.String,routingnumber);
58 dbCmdWrapper.AddInParameter("@accountnumber",DbType.String,enc_accountnumber);
59 dbCmdWrapper.AddInParameter("@checknumber",DbType.String,checknumber);
60 dbCmdWrapper.AddInParameter("@nameoncard",DbType.String,nameoncard);
61 dbCmdWrapper.AddInParameter("@cardnumber",DbType.String,enc_cardnumber);
62 dbCmdWrapper.AddInParameter("@cardverifynum",DbType.Int32,cardverifynum);
63 dbCmdWrapper.AddInParameter("@cardexpirationdate",DbType.DateTime,cardexpiredate);
64 dbCmdWrapper.AddInParameter("@billaddress1",DbType.String,address1);
65 dbCmdWrapper.AddInParameter("@billaddress2",DbType.String,address2);
66 dbCmdWrapper.AddInParameter("@billcity",DbType.String,city);
67 dbCmdWrapper.AddInParameter("@billstate",DbType.String,state);
68 dbCmdWrapper.AddInParameter("@billzip",DbType.String,zip);
69 dbCmdWrapper.AddInParameter("@billphone",DbType.String, phone);
70 dbCmdWrapper.AddInParameter("@ip",DbType.String, ip);
71 dbCmdWrapper.AddInParameter("@fISN",DbType.Int32, fISN);
72 dbCmdWrapper.AddInParameter("@price",DbType.Currency, grand_total);
73 dbCmdWrapper.AddInParameter("@description",DbType.String, product_desc);
74 dbCmdWrapper.AddInParameter("@bqaction",DbType.String, bqAction);
75 dbCmdWrapper.AddInParameter("@creditamount",DbType.Currency, 0);
76 dbCmdWrapper.AddInParameter("@processor",DbType.String, whichProcessor);
77 db.ExecuteNonQuery(dbCmdWrapper) ;
78
79 returnedbqISN = bqISN;
80 }
81 else
82 {
83 //insert into billingQ or update if bqISN is passed
84 sql = "spInsertBillingQ";
85 dbCmdWrapper = db.GetStoredProcCommandWrapper(sql);
86 dbCmdWrapper.AddInParameter("@lISN",DbType.Int32,lISN);
87 dbCmdWrapper.AddInParameter("@mISN",DbType.Int32,mISN);
88 dbCmdWrapper.AddInParameter("@email",DbType.String,customer_email);
89 dbCmdWrapper.AddInParameter("@bankname",DbType.String,bankname);
90 dbCmdWrapper.AddInParameter("@routingnumber",DbType.String,routingnumber);
91 dbCmdWrapper.AddInParameter("@accountnumber",DbType.String,enc_accountnumber);
92 dbCmdWrapper.AddInParameter("@checknumber",DbType.String,checknumber);
93 dbCmdWrapper.AddInParameter("@nameoncard",DbType.String,nameoncard);
94 dbCmdWrapper.AddInParameter("@cardnumber",DbType.String,enc_cardnumber);
95 dbCmdWrapper.AddInParameter("@cardverifynum",DbType.Int32,cardverifynum);
96 dbCmdWrapper.AddInParameter("@cardexpirationdate",DbType.DateTime,cardexpiredate);
97 dbCmdWrapper.AddInParameter("@billaddress1",DbType.String,address1);
98 dbCmdWrapper.AddInParameter("@billaddress2",DbType.String,address2);
99 dbCmdWrapper.AddInParameter("@billcity",DbType.String,city);
100 dbCmdWrapper.AddInParameter("@billstate",DbType.String,state);
101 dbCmdWrapper.AddInParameter("@billzip",DbType.String,zip);
102 dbCmdWrapper.AddInParameter("@billphone",DbType.String, phone);
103 dbCmdWrapper.AddInParameter("@ip",DbType.String, ip);
104 dbCmdWrapper.AddInParameter("@fISN",DbType.Int32, fISN);
105 dbCmdWrapper.AddInParameter("@price",DbType.Currency, grand_total);
106 dbCmdWrapper.AddInParameter("@description",DbType.String, product_desc);
107 dbCmdWrapper.AddInParameter("@bqaction",DbType.String, bqAction);
108 dbCmdWrapper.AddInParameter("@creditamount",DbType.Currency, 0);
109 dbCmdWrapper.AddInParameter("@processor",DbType.String, whichProcessor);
110 returnedbqISN = 0;
111 returnedbqISN = (Int32)db.ExecuteScalar(dbCmdWrapper) ;
112
113 }
114
115
116
117 //bill credit card or ACH
118 switch (ccORach.Trim())
119 {
120 case "CC":
121 retBilling = BillCreditCard(whichProcessor,ip,merchant_email,grand_total, strFirstName.Trim(), strLastName.Trim(),
122 city,state, phone, address1,address2, zip, customer_email,
123 product_desc, socialsecuritynum,creditcardnumber, cardverifynum, cardexpiredate,returnedbqISN,
124 ref AuthCode, ref OrderNumber, ref DeclineCode, ref TermCode, ref ErrorMessage, ref ProcessorResponse,
125 authenticationValue,authenticationTransactionID, eci, transactiontype, PAResStatus, SignatureVerification);
126 break;
127 case "ACH":
128 retBilling = BillACH(whichProcessor, ip,merchant_email, grand_total, firstname, lastname,
129 city,state, phone, address1,address2, zip, customer_email,
130 product_desc, socialsecuritynum,bankname, routingnumber, accountnumber, checknumber, returnedbqISN,
131 ref AuthCode, ref OrderNumber, ref DeclineCode, ref TermCode, ref ErrorMessage, ref ProcessorResponse);
132 break;
133 case "PAYPAL":
134 retBilling = BillPayPal(ip,merchant_email,grand_total,firstname,lastname,
135 city,state,phone,address1,address2,zip,customer_email,
136 product_desc,socialsecuritynum,returnedbqISN, paypalSubAgreeID, notificationLocation,
137 ref strErrorNo, ref strErrorDesc, ref strTransactionId, ref strStatus,
138 ref strStatusCode, ref strReasonCode);
139 break;
140 }
141
142 //insert into billingDetail
143 char bqRecurring = 'N';
144 sql = "spInsertBillingDetail2";
145 dbCmdWrapper = db.GetStoredProcCommandWrapper(sql);
146
147 dbCmdWrapper.AddInParameter("@mISN",DbType.Int32,mISN);
148 dbCmdWrapper.AddInParameter("@bqISN",DbType.Int32,returnedbqISN);
149 dbCmdWrapper.AddInParameter("@bdamountcollected",DbType.Currency,grand_total);
150 dbCmdWrapper.AddInParameter("@bdtransactioncode",DbType.String,AuthCode);
151 dbCmdWrapper.AddInParameter("@bdstatus",DbType.Boolean,retBilling);
152 dbCmdWrapper.AddInParameter("@bdauthcode",DbType.String,AuthCode);
153 dbCmdWrapper.AddInParameter("@bdordernumber",DbType.String,OrderNumber);
154 dbCmdWrapper.AddInParameter("@bdtracecode",DbType.String,returnedbqISN);
155 dbCmdWrapper.AddInParameter("@email",DbType.String,customer_email);
156 dbCmdWrapper.AddInParameter("@bankname",DbType.String,bankname);
157 dbCmdWrapper.AddInParameter("@routingnumber",DbType.String,routingnumber);
158 dbCmdWrapper.AddInParameter("@accountnumber",DbType.String,enc_accountnumber);
159 dbCmdWrapper.AddInParameter("@checknumber",DbType.String,checknumber);
160 dbCmdWrapper.AddInParameter("@nameoncard",DbType.String,nameoncard);
161 dbCmdWrapper.AddInParameter("@cardnumber",DbType.String,enc_cardnumber);
162 dbCmdWrapper.AddInParameter("@cardverifynum",DbType.Int32,cardverifynum);
163 dbCmdWrapper.AddInParameter("@cardexpirationdate",DbType.DateTime,cardexpiredate);
164 dbCmdWrapper.AddInParameter("@billaddress1",DbType.String,address1);
165 dbCmdWrapper.AddInParameter("@billaddress2",DbType.String,address2);
166 dbCmdWrapper.AddInParameter("@billcity",DbType.String,city);
167 dbCmdWrapper.AddInParameter("@billstate",DbType.String,state);
168 dbCmdWrapper.AddInParameter("@billzip",DbType.String,zip);
169 dbCmdWrapper.AddInParameter("@billphone",DbType.String, phone);
170 dbCmdWrapper.AddInParameter("@ip",DbType.String, ip);
171 dbCmdWrapper.AddInParameter("@bqrecurring",DbType.String, bqRecurring);
172 dbCmdWrapper.AddInParameter("@Message",DbType.String, ErrorMessage);
173 dbCmdWrapper.AddInParameter("@ProcessorResponse",DbType.String, ProcessorResponse);
174 dbCmdWrapper.AddInParameter("@processor",DbType.String, whichProcessor);
175
176 dbCmdWrapper.AddInParameter("@strErrorNo",DbType.String, strErrorNo);
177 dbCmdWrapper.AddInParameter("@strErrorDesc",DbType.String, strErrorDesc);
178 dbCmdWrapper.AddInParameter("@strTransactionId",DbType.String, strTransactionId);
179 dbCmdWrapper.AddInParameter("@strStatus",DbType.String, strStatus);
180 dbCmdWrapper.AddInParameter("@strStatusCode",DbType.String, strStatusCode);
181 dbCmdWrapper.AddInParameter("@strReasonCode",DbType.String, strReasonCode);
182
183
184 Int32 returnedbdISN = 0;
185 returnedbdISN = (Int32)db.ExecuteScalar(dbCmdWrapper) ;
186 if (retBilling)
187 {
188 if (UpdateBillingQStatuses(strDBInstance,returnedbqISN,'S'))
189 {
190 return true;
191 }
192 }
193 else
194 {
195 if (UpdateBillingQStatuses(strDBInstance,returnedbqISN,'F'))
196 {
197 return false;
198 }
199 }
200 return false;
201
202 }
View 2 Replies
View Related
Aug 15, 2004
Well I made a bussiness object for registering users as well as logging them in. I dont know if my bussiness obect is screwed up or if its the database, or the SQL syntax or what. Please take a look at this. I am not getting any error messages, but nothing is being added to the server. I am using MSDE for the SQL Server.
Here's my bussiness object:
Imports System
Imports System.Data
imports System.Data.oledb
NameSpace LoveShare
Public Class UserDetails
public UserID AS Integer
public FirstName AS String
public LastName AS String
public UserName AS string
public Password AS String
public Address AS String
public City AS String
public State AS String
public Zip As Integer
public Email AS String
End Class
Public Class User
Private objConn As New oledbConnection("Provider=sqloledb;Data Source=GARAGESALELOVESHARE;Initial Catalog=LoveShare1;User Id=sa;Password=notonthispost;")
Public function Login(strUsername AS String, strPassword As String) As Integer
dim intID as integer
dim objparam AS new oledbparameter
dim objcmd AS oledbCommand
objCmd = new oledbCommand("dbo.SPLoginUser", objconn)
objcmd.commandtype = commandtype.Storedprocedure
objparam = New oledbparameter("@UserName", oledbtype.Char)
objParam.Value = strUserName
objCmd.Parameters.Add(objParam)
objParam = New oledbParameter("@Password", OleDbType.Char)
objParam.Value = strPassword
objCmd.Parameters.Add(ObjParam)
Try
objConn.Open
intID = CType(objCmd.ExecuteScalar, Integer)
objConn.Close
Catch e As Exception
Throw e
End Try
If intID.toString = "" Then
return 0
End if
Return intID
end function
Public Sub AddUser(objUser As UserDetails)
Dim intId as integer
Dim objReader As oledbdataReader
Dim objCmdID As New oledbCommand("SELECT MAX(userID) FROM tblUsers", objconn)
Dim objcmd AS New oleDBCommand("spAddUser", objConn)
Dim objparam AS OleDbParameter
objCmd.CommandType = CommandType.StoredProcedure
objParam = New oleDbParameter("@FirstName", oledbtype.Char)
objParam.value = objuser.FirstName
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@LastName", oledbtype.Char)
objParam.value = objuser.LastName
objCmd.Parameters.add(objParam)
objParam = new oleDbParameter("@UserName", oledbtype.Char)
objParam.Value = objUser.UserName
objCmd.Parameters.Add(objParam)
objParam = New oleDbParameter("@Password", oledbtype.Char)
objParam.value = objuser.Password
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@Email", oledbtype.Char)
objParam.value = objuser.Email
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@Address", oledbtype.Char)
objParam.value = objuser.Address
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@City", oledbtype.Char)
objParam.value = objuser.City
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@State", oledbtype.Char)
objParam.value = objuser.State
objCmd.Parameters.add(objParam)
objParam = New oleDbParameter("@Zip", oledbtype.Integer)
objParam.value = objuser.Zip
objCmd.Parameters.add(objParam)
Try
objConn.Open
ObjCmd.ExecuteNonQuery
objUser.UserID = CType(objCmdID.ExecuteScalar, Integer)
objConn.Close
Catch e AS Exception
Throw e
End try
If objUser.UserID.ToString = "" then
objuser.UserID = 25
End if
End Sub
End Class
End NameSpace
Here's is my stored procedure for the registration:
CREATE PROCEDURE [dbo].[SPAddUser]
@FirstName VarChar(255),
@LastName VarChar(255),
@UserName VarChar(255),
@Password VarChar(255),
@Email VarChar(255),
@Address VarChar(255) ,
@City VarChar(255),
@State VarChar(255) ,
@Zip [INT]
AS
INSERT INTO tblUsers (FirstName, LastName, UserName, Password, Email, Address, City, State, Zip)
VALUES (@FirstName, @LAstName, @UserName, @Password, @Email, @Address, @City, @State, @Zip)
GO
And here is the actual registration page
<%@ Page Language="VB" %>
<%@ Register tagPrefix="LoveShare" TagName="Header" src="head.ascx" %>
<%@ Register tagPrefix="LoveShare" TagName="Menu" src="Men.ascx" %>
<%@ Register tagPrefix="LoveShare" TagName="Stats" src="Stats.ascx" %>
<%@ Register tagPrefix="LoveShare" TagName="Footer" src="foot.ascx" %>
<%@ Import Namespace="system" %>
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="LoveShare" %>
<script runat="server">
Public sub Submit(sender as object, e as eventargs)
If Page.IsValid then
dim objuserdetails as New LoveShare.UserDetails
dim objuser As New LoveShare.User
objuserDetails.FirstName=tbFirstName.Text
objuserDetails.LastName=tbLastName.Text
objUserDetails.Username=tbUserName.Text
objuserDetails.Password=tbPassword.Text
objUserDetails.Email=tbEmail.Text
objUserDetails.Address=tbAddress.Text
objUserDetails.City=tbCity.Text
objUserDetails.State=tbState.Text
objuserDetails.Zip=tbState.Text
ObjUser.AddUser(objUserDetails)
Session("UserID") = objUserDetails.UserID
FormsAuthentication.SetAuthCookie(objUserDetails.UserID, false)
Response.Redirect("index.aspx")
else
lblMessage.text="Information entered incorrectly"
End If
End Sub
</Script>
<html>
<body BGCOLOR="00ccFF">
<Table Width="800">
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<LoveShare:Header runat="server" />
</td>
</tr>
<tr>
<td>
<Table cellpadding="0" cellspacing="15" Width="800">
<tr>
<td>
</td>
<td>
<td>
<form runat="server">
<table cellpadding="3" cellspacing="0" width="100%">
<tr>
<td colspan="2" Align="center">
<Font size="6">Sign Up Today!<BR><BR></Font>
</td>
</tr>
<tr>
<td Align="Center">
<Font color="red">
<asp:label id="lblMessage" runat="server" />
</font>
</td>
</tr>
<tr>
<td Align="right">First Name:</td>
<td Align="Left"><asp:textbox id="tbFirstName" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbFirstName" ErrorMessage="First Name Required" Text="Forgot First Name" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Last Name:</Td>
<td Align="Left"><asp:textbox id="tbLastName" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbLastName" ErrorMessage="Last Name Required" Text="Forgot Last Name" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Desired UserName:</td>
<td Align="Left"><asp:textbox id="tbUserName" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbUserName" ErrorMessage="UserName required" Text="Forgot UserName" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Password:</td>
<td Align="Left"><asp:textbox id="tbPassword" Textmode="Password" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbPassword" ErrorMessage="Password Required" Text="Forgot Password" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Verify Password:</td>
<td Align="Left"><asp:textbox id="tbVPassword" Textmode="password" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbVPassword" ErrorMessage="Verify Password" Text="Forgot to verify Password" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Email Address:</td>
<td Align="Left"><asp:textbox id="tbEmail" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbEmail" ErrorMessage="Email address required" Text="Forgot Email address" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Verify Email Address:</td>
<td Align="Left"><asp:textbox id="tbVEmail" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbVEmail" ErrorMessage="Must verify Email address" Text="Verify Email address" Display="Dynamic"/>
</td>
</tr>
<td Align="right">Street Address</td>
<td Align="Left"><asp:textbox id="tbAddress" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbAddress" ErrorMessage="Street Address Required" Text="Forgot Address" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">City:</td>
<td Align="Left"><asp:textbox id="tbCity" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbCity" ErrorMessage="City Required" Text="Forgot City" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">State:</td>
<td Align="Left"><asp:textbox id="tbState" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbState" ErrorMessage="State Required" Text="Forgot State" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right">Zip:</td>
<td Align="Left"><asp:textbox id="tbZip" runat="server" />
<asp:requiredfieldValidator runat="server" Controltovalidate="tbZip" ErrorMessage="Zip Code Required" Text="Forgot Zip" Display="Dynamic"/>
</td>
</tr>
<tr>
<td Align="right"> </td>
<td Align="Left"><asp:button id="btsignup" text="Sign Up" onclink="submit" runat="server" />
</tr>
</table>
</form>
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
</tr>
<td>
</td>
</tr>
<tr>
<td>
<LoveShare:Footer runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Please help, I cannot figure out what is wrong
View 1 Replies
View Related