0

我正在尝试实现 Windows azure 表存储...但我得到“找不到表”

这是我的连接字符串(如何在这里发布我的 xml?)(对不起链接)

ServiceConfiguration.Cloud.cscfg: http: //pastebin.com/F9tuckfT

ServiceConfiguration.Local.cscfg:

http://pastebin.com/XZHEvv6g

这里有一个来自我的 Windows azure 门户的打印屏幕

http://s20.postimage.org/nz1sxq7hp/print.png

代码(对不起,更长的代码...但是有三页...登录有效,当我登录时,转到调用 grid.aspx 的 main.aspx ...在 grid.aspx 中我收到错误“表不是发现“所有这些代码对于这个问题都很重要.....) http://pastebin.com/RnuvvqsM

我试过了

private void popula()
    {
        var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
        account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
        var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);

        Hashtable ht = (Hashtable)ViewState["filtro"];

        if (ht == null)
            GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
        else
            GridView1.DataSource = context.SelectConc(ht);

        GridView1.DataBind();
    }

但它也不起作用

其他类似的错误是当我尝试在表中添加用户时

public string addusr(string nome, string cidade, string cpf, string email, string telefone)
    {
        try
        {
            if (nome.Length == 0)
                return "f:Preencha o campo nome.";

            if (cidade.Length == 0)
                return "f:Preencha o campo cidade.";

            if (cpf.Length == 0)
                return "f:Preencha o campo cpf.";

            if (!Valida(cpf))
                return "f:CPF Invalido.";

            if (email.Length == 0)
                return "f:Preencha o campo email.";

            Regex rg = new Regex(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");
            if (!rg.IsMatch(email))
            {
                return "f:Email Invalido";
            }

            List<UserEntity> lst = new List<UserEntity>();
            var _account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
            _account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
            var _context = new CRUDUserEntities(_account.TableEndpoint.ToString(), _account.Credentials);


            var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
            account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
            var context = new CRUDUserEntities(account.TableEndpoint.ToString(), account.Credentials);
            UserClientEntity entity = new UserClientEntity() { nome = nome, cidade = cidade, cpf = cpf, email = email, telefone = telefone };
            context.ADDUSociate(entity);
            context.SaveChanges();
            return "k";
        }

我收到此错误: f:处理此请求时发生错误。| 在 System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse() 在 System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest() 在 System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions 选项) 在 AzureTableLayer .CRUDUserEntities.ADDUSociate(UserClientEntity entity) at mobile.Service1.addusr(String nome, String cidade, String cpf, String email, String telefone)

我相信这两个问题是相关的

编辑:我已调试并发现无法加载 StorageClient 框架...我收到此错误无法加载文件或程序集 Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

怎么解决?

4

2 回答 2

1

您如何尝试使用表存储?使用 .NET SDK?php?爪哇?节点?...通常,如果您收到此错误,则意味着...该表不存在。

检查您正在使用的 SDK 是否有类似于CreateIfNotExists的方法,以便在开始使用之前创建表。

编辑:

问题可能发生在这里:

        var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
        var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);

        Hashtable ht = (Hashtable)ViewState["filtro"];

        if (ht == null)
            GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
        else
            GridView1.DataSource = context.SelectConc(ht);

account = ...在 var行之后添加以下代码:

     account.CreateCloudTableClient().CreateTableIfNotExist("<name of your table>");
于 2013-01-17T14:59:09.787 回答
0

API 已更改。你需要这样做:

var key = CloudConfigurationManager.GetSetting("Setting1");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(key);
var client = storageAccount.CreateCloudTableClient();

CloudTable table = client.GetTableReference(ContactTableName);
table.CreateIfNotExists();
于 2013-02-25T14:03:02.293 回答