【发布时间】:2013-03-05 08:34:49
【问题描述】:
我正在使用 asp.net c# 和 Mysql 进行在线购物项目。我正在使用 Devart Linqconnect (LinqtoMysql)。我在 mysql 客户和客户地址中有两个表:
客户表
客户 ID 整数
Customerhone varchar(20);
客户密码 Varchar(20);
电子邮件 varchar(20)
名字 char(50)
姓(50)
用户名 varshar(50)
客户地址
Customer_address_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Customer_ID INT NOT NULL,
地址1 CHAR(250),
地址2 CHAR(250),
城市 CHAR(20),
状态 CHAR(20),
密码 VARCHAR(20),
主键(客户地址 ID),
FOREIGN KEY (Customer_ID) REFERENCES customers(Customer_ID)
当我在使用 LINQ to mysql 注册客户时编写此代码时:
using (ShoppingDataContext data = new ShoppingDataContext())
{
Customer NewCustomer = new Customer();
CustomerAddress newaddress = new CustomerAddress();
newaddress.CustomerID = NewCustomer.CustomerID;
NewCustomer.CustomerFirstname = TextBoxFirstName.Text;
NewCustomer.CustomerLastname = TextBoxLastname.Text;
NewCustomer.CustomerEmail = TextBoxEmail.Text;
NewCustomer.Username = TextBoxusername.Text;
NewCustomer.CustomerPassword = TextBoxPassword.Text;
newaddress.Address1 = TextBoxAddress1.Text;
newaddress.Address2 = TextBoxAddress2.Text;
newaddress.City = TextBoxCity.Text;
newaddress.State = TextBoxState.Text;
newaddress.Pincode = TextBoxPincode.Text;
System.Web.Security.Membership.CreateUser(TextBoxusername.Text, TextBoxPassword.Text);
data.Customers.InsertOnSubmit(NewCustomer);
PanelRegister.Visible = false;
ConfimPanel.Visible = true;
}
此代码是否可以将数据插入到两个表中。请帮忙。 customer_address表能否根据customerId为外键,检测出输入的客户地址是customer表的?
我正在使用 ajax 工具包的模态弹出面板,并在面板中添加了注册和登录表。
我的注册面板:
提前谢谢...
【问题讨论】:
-
我现在已经尝试过了,我收到了这个可怕的错误:视图状态 MAC 验证失败。如果此应用程序由 Web Farm 或集群托管,请确保
配置指定相同的验证密钥和验证算法。 AutoGenerate 不能在集群中使用。 -
抱歉问了这么长的问题..
标签: c# asp.net mysql database-design linq-to-sql