Laploy Web Board
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน

2 posters

Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน

ตั้งหัวข้อ  XitToKvp 26th August 2011, 1:56 pm

ผมกำลังหัดเขียนเองนะครับ โดยอิงตามหนังสือ แต่เขียนถึงตรงนี้มัน ขึ้น ว่า "A get or set accesser expected "เข้าใจว่ามันบอกใส่กำหนด set และ get ผมไม่รู้ว่าต้อง สร้างตรงไหนครับ ซึ่งมันต่างจากโคดของอาจารย์ลาบลอยตรงไหนครับ ใครเจอแบบผมบ้างแนะนำด้วยครับ
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;

namespace WebAppFac
{
public static class GlobalVar
{
#region String Literal
public const string ConnString = @"Provider=SQLOLEDB;Data Source=NB;Initial Catalog=SecurityTutorials;User Instance=True;User Id=sa; Password=nc4400";
#endregion

#region Literal
public static string[] ContactDetails {
"Name",
"Lastname",
"Email",
"Address",
"SubDistrict",
"District",
"Province",
"PostalCode",
"Mobile",
"Telephone"
}; //ปัญหาเกิดที่ Name เป็นจุดแรก
#endregion
}
}
#####################################
Code ของอาจารย์
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public struct databaseParam
{
public string productID;
#########
}

public static class GlobalVar
{
#region string Literal
##############
#endregion

#region Menu literal
public static string[] menuText =
{
" Home page",
" Company profile",
" Our strength",
" Mission",
" Quality Assurance",
" R & D",
" Product Range",
" Product Category",
" Sign in",
" User Management"
};
public static string[] menuURL =
{
"Default.aspx",
"CompanyProfile.aspx",
"Strength.aspx",
"Mission.aspx",
"QA.aspx",
"RD.aspx",
"Ranges.aspx",
"ProductCat.aspx",
"UserLogIn.aspx?Cat=x",
"UserListShow.aspx"
};
#endregion

#region Background & Color scheme
public static string[] catBkgName =
{
"bkg-green2.gif",
"bkg-blue2.gif",
"bkg-red2.gif",
"bkg-orange.gif",
"bkg-yellow.gif",
"bkg-purple.gif",
"bkg-brown.gif"
};
public static string[] catMainColor =
{
"#4D6E25", // green
"#15557F", // blue
"#B43B02", // red
"#D67B00", // orange
"#EAB100", // yellow
"#973BB8", // purple
"#924823" // brown
};
public static string[] catTailColor =
{
"#385816", // green
"#103F5E", // blue
"#662101", // red
"#AA6100", // orange
"#CC9A00", // yellow
"#5E2573", // purple
"#602F17" // brown
};
public static string[] catHiColor =
{
"#678345", // green
"#3581B2", // blue
"#BE5625", // red
"#DB891C", // orange
"#EDBE2A", // yellow
"#A24FBF", // purple
"#A26344" // brown
};
public static string[] catLowColor =
{
"#647013", // green
"#114669", // blue
"#963102", // red
"#C06E00", // orange
"#DAA500", // yellow
"#8735A5", // purple
"#82401F" // brown
};
#endregion

#region Category literal
public static string[] catTitleText =
{
"Fashion & Clothing",
"Art & Crafts",
"Home & Garden",
"Spots & Leisure",
"Fabrics & Accessories",
"Others",
"Home",
};

public static string[] catMenuText =
{
"Fashion & Clothing",
"Art & Crafts",
"Home & Garden",
"Spots & Leisure",
"Fabrics & Accessories",
"Others",
"Home",
};

public static string[] catMenuURL =
{
"ShowCategory.aspx?cat=0",
"ShowCategory.aspx?cat=1",
"ShowCategory.aspx?cat=2",
"ShowCategory.aspx?cat=3",
"ShowCategory.aspx?cat=4",
"ShowCategory.aspx?cat=5",
"default.aspx",
};

public static string[] ProductDetail =
{
"Product ID",
"Category",
"Common Name",
"Brand Name",
"Origin",
"Form",
"Size",
"Description",
"Price",
"Image File",
"Process"
};
#endregion

#region public constant
public const int mainMenuCount = 9; /* 0 - 9 are 10 menu items */
public const int catMenuCount = 7; /* total categoary shown in menu */
public const int catColorCount = 7; /* number of color scheme for catalog list page */
public const int category = 0; /* default category */
public const int pageHeight = 528; /* this web normal page size = 800x528 */
public const int addressBarTop = 535; /* position of address bar */
public const string addressBarColor = "#3581B2"; /* color of homepage address bar */
public const int catTopPost = 132; /* start position of catalog screen */
public const int thumbHeight = 90; /* height of each product */
#endregion

#region server folder specific
public const string defaultBkgImage = "bkg-blue1.gif";
public const string imagePath = @"images/";
public const string imageGap = imagePath + "gap10x10.gif";
public const string imageBlackLine = imagePath + "line.jpg";
public const string dataPath = @"data/";
public const string productImageThumbPath = @"product-thumb/";
public const string productImageDetailPath = @"product-detail/";
public const string productImageBigPath = @"product-big/";
//public const string currencyData = @"C:\websites\laploy\thailand2siam\data\currency.txt";
public const string currencyData = @"d:\websites\laploy\thailand2siam.com\data\currency.txt";
#endregion
}

Download Code ของอาจารย์มาจากที่นี่
https://skydrive.live.com/?cid=4D52C1812766D2D7&id=4D52C1812766D2D7!1492

ผมแค่จะลองทำเล็กๆน้อยไปเรื่อยๆ โดยเริ่มจาก เพิ่มข้อมูลตัวอย่างเล็กๆ

หน้าเพิ่มข้อมูลของผม
ResumeRegister .ASPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebAppFac.Account
{
public partial class ResumeRegister : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnCreate_Click(object sender, EventArgs e)
{
Contact contact = new Contact();
contact.Create();
}
}
}
#########################
Class ในการจัดการ
Contact.CS
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;

using System.Data.OleDb;

namespace WebAppFac
{
public class Contact
{
private OleDbConnection conn;

private string[] dateOfBirth;
private int[] sex;
private string[] name, lastName, email, address, subDistrict, district, province, postalCode, mobile, telephone;

public string[] Telephone
{
get { return telephone; }
set { telephone = value; }
}
public string[] Mobile
{
get { return mobile; }
set { mobile = value; }
}
public string[] PostalCode
{
get { return postalCode; }
set { postalCode = value; }
}
public string[] Province
{
get { return province; }
set { province = value; }
}
public string[] District
{
get { return district; }
set { district = value; }
}
public string[] SubDistrict
{
get { return subDistrict; }
set { subDistrict = value; }
}
public string[] Address
{
get { return address; }
set { address = value; }
}
public string[] Email
{
get { return email; }
set { email = value; }
}
public string[] LastName
{
get { return lastName; }
set { lastName = value; }
}
public string[] Name
{
get { return name; }
set { name = value; }
}
public string[] DateOfBirth
{
get { return dateOfBirth; }
set { dateOfBirth = value; }
}
public int[] Sex
{
get { return sex; }
set { sex = value; }
}

public Contact()
{
conn = new OleDbConnection();
}
private OleDbConnection ConnectToDatabase(string ConnString)
{
try
{
conn.ConnectionString = ConnString;
}
catch (Exception errToAccess)
{
throw;
}

if (conn.State==ConnectionState.Open)
{
conn.Close();
}
conn.Open();
return (conn);
}


public bool Create()
{
OleDbConnection objConn = new OleDbConnection(GlobalVar.ConnString);
objConn.Open();

String sqlString = "INSERT INTO [aspnet_Contacts] ("+
" [Name],"+
" [LastName],"+
" [DateOfBirth],"+
" [Email],"+
" [Address],"+
" [Province],"+
" [District],"+
" [SubDistrict],"+
" [PostalCode,"+
" [Mobile,"+
" [Telephone,"+
" [Sex]"+
" ) VALUES ('"+
name[0]+"','"+
lastName[0]+"','"+
dateOfBirth[0]+"','"+
email[0]+"','"+
address[0]+"','"+
province[0]+"','"+
district[0]+"','"+
subDistrict[0]+"','"+
postalCode[0]+"','"+
mobile[0]+"','"+
telephone[0]+"',"+
Convert.ToInt16(sex[0])+")";

OleDbCommand objCmd = new OleDbCommand(sqlString,objConn);
bool result = false;
if (objCmd.ExecuteNonQuery()>0)
{
result = true;
}
objConn.Close();
return result;
//throw new System.NotImplementedException();
}

public void Delete()
{
throw new System.NotImplementedException();
}

public void Edit()
{
throw new System.NotImplementedException();
}

public void GetContact()
{
throw new System.NotImplementedException();
}
}
}

#############################
ASPX
ResumeRegister.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ResumeRegister.aspx.cs" Inherits="WebAppFac.Account.ResumeRegister" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<table style="width:100%;">
<tr>
<td align="center" colspan="2">
Contact Data:</td>
</tr>
<tr>
<td style="width:20%;" align="right">
Name:</td>
<td>
<asp:TextBox ID="txtName" runat="server" MaxLength="70"></asp:TextBox>
<asp:Label
ID="Label1" runat="server" Text="Required" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
Last name:</td>
<td>
<asp:TextBox ID="txtLastName" runat="server" MaxLength="70"></asp:TextBox>
<asp:Label
ID="Label2" runat="server" Text="Required" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
Date of birth:</td>
<td>
<asp:TextBox ID="txtDateOfBirth" runat="server" MaxLength="50"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Sex:</td>
<td>
<asp:RadioButton ID="rdbSexM" runat="server" GroupName="Sex" Text="Male" />
<asp:RadioButton ID="rdbSexFM" runat="server" GroupName="Sex" Text="Female" />
</td>
</tr>
<tr>
<td align="right">
Email:</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" MaxLength="100" Width="200px"></asp:TextBox>
<asp:Label
ID="Label3" runat="server" Text="Required" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
Address:</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Columns="30" MaxLength="200"
Rows="2" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
SubDistrict:</td>
<td>
<asp:TextBox ID="txtSubDistrict" runat="server" MaxLength="100"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
District:</td>
<td>
<asp:TextBox ID="txtDistrict" runat="server" MaxLength="100"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Provice:</td>
<td>
<asp:TextBox ID="txtProvince" runat="server" MaxLength="100"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
PostalCode:</td>
<td>
<asp:TextBox ID="txtPostalCode" runat="server" MaxLength="20"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Mobile:</td>
<td>
<asp:TextBox ID="txtMobile" runat="server" MaxLength="50" Width="200px"></asp:TextBox>
<asp:Label
ID="Label4" runat="server" Text="Required" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
Telephone:</td>
<td>
<asp:TextBox ID="txtTelephone" runat="server" MaxLength="50" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Button ID="btnCreate" runat="server" Text="Create"
onclick="btnCreate_Click" />
</td>
</tr>
<tr>
<td align="right">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>
</asp:Content>

############################


XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty อีเมลโปรเจกต์

ตั้งหัวข้อ  Admin 2nd September 2011, 7:43 pm

zip แล้วอีเมลโปรเจกต์มาหน่อยครับ อ่านในนี้แล้วไม่ค่อยรู้เรื่อง

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ส่งเมลไปแล้วครับ

ตั้งหัวข้อ  XitToKvp 3rd September 2011, 2:03 pm

ผมส่งเมลไปแล้วนะครับ รายละเอียดตามในอีเมลเลยครับ

XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ส่งเมลไม่ได้ครับ มันตีกลับ

ตั้งหัวข้อ  XitToKvp 4th September 2011, 8:01 pm

This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

laploy@gmail.com

XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty อีเมลหลัก

ตั้งหัวข้อ  Admin 4th September 2011, 11:23 pm

laploy@gmail.com เป็นอีเมลหลักที่ผมใช้อยู่ตลอดเวลาครับ ลองดูใหม่

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ส่งเมลไม่ได้เลย

ตั้งหัวข้อ  XitToKvp 5th September 2011, 8:45 am

อันนี้ส่งจาก hotmail --->
This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

laploy@gmail.com

#######################
อันนี้จาก yahoo-->
Hi. This is the qmail-send program at yahoo.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<laploy@gmail.com>:
209.85.225.27 failed after I sent the message.
Remote host said: 552-5.7.0 Our system detected an illegal attachment on your message. Please
552-5.7.0 visit http://mail.google.com/support/bin/answer.py?answer=6590 to
552 5.7.0 review our attachment guidelines. w3si4357452icz.83
##########################



XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ส่งไม่ได้เพราะ attach file

ตั้งหัวข้อ  Admin 5th September 2011, 9:59 am

ดูจาก error message ที่คุณให้มาพบว่า
สาเหตุที่ส่งไม่ได้เพราะ attach file เป็น zip หรือ exe ด้วยเหตุผลทางความปลอดภัย
วิธีแก้คือ ให้เปลี่ยนนามสกุลของไฟล์จาก zip เป็น zipp เสียก่อน

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ทดลองส่งเมลเปล่าๆไปดูนะครับ

ตั้งหัวข้อ  XitToKvp 9th September 2011, 9:23 am

ส่งแต่เมลเปล่าๆไปดูนะครับ

XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ส่งเมล และแนบไฟล์

ตั้งหัวข้อ  XitToKvp 9th September 2011, 10:49 am

ผมส่งเมลและแนบไฟล์ทั้งหมดไปแล้วนะครับ
รบกวนดูให้นิดนะครับ
ขอบคุณครับ

XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ว่างแล้ว

ตั้งหัวข้อ  Admin 9th September 2011, 2:37 pm

ได้รับอีเมลและไฟล์แนบแล้ว เดียวว่างแล้วจะดูให้ครับ

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty แบบนี้

ตั้งหัวข้อ  Admin 9th September 2011, 9:02 pm

ให้แก้เป็นแบบนี้

public static string[] ContactDetails = new string[] {
"Name",
"Lastname",
"Email",
"Address",
"SubDistrict",
"District",
"Province",
"PostalCode",
"Mobile",
"Telephone"
};

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

A get or set accesser expected ขึ้นบอกแต่ไม่รู้ว่าตรงไหน Empty ขอบคุณอาจารย์มากครับ

ตั้งหัวข้อ  XitToKvp 19th September 2011, 8:19 am

ขอบคุณอาจารย์มากๆครับ แต่ว่ายังไม่ได้ลองเลย

XitToKvp

จำนวนข้อความ : 13
Join date : 10/03/2010

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน


 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ