我創建了一個azure移動服務並正確設置了所有數據庫表(測試它們)。但是,當我嘗試通過我的Android應用程序向我的SQL表中插入記錄時,記錄不會被添加。 (是的,我的SQL表也準備好了移動服務,也改變了模式)Azure移動服務:無法向表中插入任何記錄?
我也沒有收到錯誤。
這裏是我的代碼:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_screen);
final String mobileServiceUrl =
"https://MY_AZURE_MOBILE_URL.net/tables/UserTable";
final String mobileServiceAppId =
"MY_MOBILESERVICE_APPID";
try {
// Create the Mobile Service Client instance, using the provided
// Mobile Service URL and key
mClient = new MobileServiceClient(
mobileServiceUrl,
mobileServiceAppId,
this);
// Get the Mobile Service Table instance to use
mToDoTable = mClient.getTable(UserTable.class);
} catch (MalformedURLException e) {
}
Button regiBtn = (Button) findViewById(R.id.signupDivertBtn);
regiBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try
{
UserTable user = new UserTable();
user.setPassword("111");
user.setFname("TESTName");
user.setId("234232");
user.setEmail("[email protected]");
mToDoTable.insert(user);
}
爲什麼沒有mToDoTable.Insert()語句的工作?將記錄插入天藍色表格不正確嗎?
編輯:
這裏是我的用戶表的實體類:
public class UserTable {
@com.google.gson.annotations.SerializedName("id")
private String id;
@com.google.gson.annotations.SerializedName("Email")
private String email;
@com.google.gson.annotations.SerializedName("Password")
private String password;
@com.google.gson.annotations.SerializedName("UserFName")
private String fname;
public UserTable()
{
}
public UserTable(String id, String email, String password, String fname) {
this.setId(id);
this.setEmail(email);
this.setPassword(password);
this.setFname(fname);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
嗯我試過這種URL格式,但仍然沒有運氣。我的插入代碼是否正確? – user3306938
您是否更改了插入操作的權限? – CSharpRocks
不,我沒有。請解釋親愛的先生:) – user3306938