-1
我想将一些数据保存到多台PC的一张表中。但是数据有一个手动填充的索引(ID)和先前的数据(ID)的顺序,所以我首先在数据库上检查它然后增加它。问题是如果多个PC /设备一起保存,它将保存相同结果。如何解决这个问题呢?如何将数据从多台PC保存到一张表SQL
这是搜索,所使用的最后一个ID查询:
> public DataRow GetPlayerIDByClient(object clientPK)
> {
> DataRow result = null;
>
> if (clientPK != null)
> {
> IDbDataParameter clientFKParam = this.CreateParameter(csPlayerNamesEntity.Names.ClientFK, clientPK);
>
> string selectCommand = string.Format("SELECT TOP 1 * FROM {0} WHERE {1} = {3} AND " +
> "({2} LIKE 'G%' or {2} LIKE 'g%') ORDER BY {4} DESC",
> csPlayerNamesEntity.Names.TableName, //0
> csPlayerNamesEntity.Names.ClientFK, //1
> csPlayerNamesEntity.Names.ID,//2
> clientFKParam,//3
> csPlayerNamesEntity.Names.PK); //4
>
> DataTable dt = this.ExecReaderDataTable(selectCommand, clientFKParam);
>
> if (dt != null && dt.Rows.Count > 0)
> {
> result = dt.Rows[0];
> }
> }
>
> return result;
> }
您是否听说过实体框架?在处理ASP.NET MVC应用程序中的数据库时,它会让你的生活更轻松。 – Robert
这是一个设计问题。你有多种可能的解决方案。您可以从中央实例同步客户端。或者,最好将数据写入导入表中,并让数据库上的作业将导入的数据传输到生产表。 –
SQL Server为您提供解决此问题的解决方案。例如,您可以为ID列使用和标识列(自动增量),或者可以使用序列来检索下一个ID。 Google for SQL Server序列。 –