sql server-winfopm程序实现sqlserver数据库表传值

问题描述

winfopm程序实现sqlserver数据库表传值

现有2张表 :A、B都在数据库C中 sqlserver数据库
A(ID、Name、Age、Account)
B(UserID、Name、Age、Account)
现在 A表中 只有 ID 、 Name有全部信息,Age、Account 只有部分有信息,B表每项都有全部信息,A表的Name在B表中都存在,现要把B表的Age、Account值 添加到 A表中没有该值得地方。 请问用 C# winform 该怎么做啊 跪求,急!!!!!!

解决方案

update a set a.age=b.age, a.count = b.count from a,b where a.id=b.userid and (a.age = null or a.account = null)

解决方案二:

update a set a.age=b.age, a.count = b.count from a,b where a.id=b.userid

解决方案三:

string strCon = @"Data Source=Localhost;Database=school;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(strCon);
sqlCon.Open();
string sql = string.Format("update yProposalMain_ProposalMainFeedbackInfo set yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserGuid=yProposalMain_ProposalMainInfo.yProposerGuid,yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserName=yProposalMain_ProposalMainInfo.yProposerName from yProposalMain_ProposalMainFeedbackInfo,yProposalMain_ProposalMainInfo where yProposalMain_ProposalMainFeedbackInfo.yProposalGuid=yProposalMain_ProposalMainInfo.yProposalGuid and(yProposalMain_ProposalMainFeedbackInfo.yProposalGuid=null or yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserName)");
SqlCommand cmd = new SqlCommand(sql, sqlCon);
int result=cmd.ExecuteNonQuery();
if (result >0 )
{
MessageBox.Show("更新成功");
}
else
{
MessageBox.Show("更新失败");
}
sqlCon.Close();

解决方案四:

and后面加上一个空格看看。

解决方案五:

update yProposalMain_ProposalMainFeedbackInfo set yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserGuid=yProposalMain_ProposalMainInfo.yProposerGuid,yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserName=yProposalMain_ProposalMainInfo.yProposerName from yProposalMain_ProposalMainFeedbackInfo,yProposalMain_ProposalMainInfo where yProposalMain_ProposalMainFeedbackInfo.yProposalGuid=yProposalMain_ProposalMainInfo.yProposalGuid and(yProposalMain_ProposalMainFeedbackInfo.yProposalGuid IS NULL or yProposalMain_ProposalMainFeedbackInfo.yFeedbackUserName)

时间: 2024-09-15 23:38:48

sql server-winfopm程序实现sqlserver数据库表传值的相关文章

Oracle SQL Server MySQL查看当前所有数据库表名及其他信息

环境:Oracle 11g + SQLServer 2008 R2 + MySQL 5.1 Oracle: 1. 查看当前库的所有数 据表 select * from all_tables; select table_name from all_tables; select table_name from user_tables; select table_name from all_tables where owner='用户名'; 2. 查看表结构 desc 表名 : SQLServer:

SQL SERVER统计服务器所有的数据库(数据库文件)、表(表行数)、字段(各字段)等详细信息

原文:SQL SERVER统计服务器所有的数据库(数据库文件).表(表行数).字段(各字段)等详细信息 USE STAT GO SET NOCOUNT ON IF EXISTS(SELECT 1 FROM SYS.TABLES WHERE TYPE='U' AND name='DBInfo') DROP TABLE DBInfo IF EXISTS(SELECT 1 FROM SYS.TABLES WHERE TYPE='U' AND name='ColumnsInfo') DROP TABLE

sql server实现在多个数据库间快速查询某个表信息的方法

本文实例讲述了sql server实现在多个数据库间快速查询某个表信息的方法.分享给大家供大家参考,具体如下: 最近出来实习,所在公司的服务器有十几个数据库,为了方便根据某个数据表的  表名  快速找到对应的数据库,又复习了一下游标的知识,写了下面这个sql代码,方便自己的工作. 1.先了解一下系统存储过程和系统表的使用,简单介绍一下我用到的几个系统存储过程(资料参考网络) use master --切换到系统数据库,因为下面用到的系统存储过程和系统表大部分存在于该数据库 go exec sp_

数据库-新手求教SQL server语句 求和,多个表之间的操作

问题描述 新手求教SQL server语句 求和,多个表之间的操作 SQL求和插入,求C表更新每个OrderID的SUM_Fee,SUM_Fee对应B表每个OrderId的总和(A表的B_ID对应B表的ID,B_ID记录单个Fee)? 解决方案 SQL Server 2005 用触发器跟踪表操作 解决方案二: update C set SUM_Fee=(select SUM(orderid) from B where B.orderid=C.orderid)没看懂A表,不是太明确的需求... 解

在sqlserver 数据库表中插入中文,查看表,中文显示乱码

问题描述 在sqlserver 数据库表中插入中文,查看表,中文显示乱码 sprintf(szSQL,"insert into %s (fromid,toid,time,msg,fontface,fontsize,fontcolor,fontflags) VALUES (%u,%u,%u,'%s','%s',%u,%u,%u)",TABLE_IM_MSG,ulFromID,ulToID,tCurrentTime,strMsg.c_str(),strfontface.c_str(),fo

如何使用SQL Server数据转换服务升迁Access数据库

本文详细介绍了如何使用SQL Server数据转换服务升迁Access数据库 开发者常常以Access作为原型或者用Access来开发不是很关键的应用程序.但是,随着公司业务的增长,要解决的问题会变得越来越复杂,Access环境可能无法满足需要.目前,Access 2002的.mdb和.adp文件都将一个数据库的长度限制在2 GB以内.这意味着几乎每个Access和SQL Server开发者最终都要将一个Access数据库升迁成一个SQL Server数据库. 由于升迁已成为极为常见的一个任务,

software-标题: SQL Server 安装程序失败。

问题描述 标题: SQL Server 安装程序失败. 标题: SQL Server 安装程序失败. SQL Server 安装程序遇到以下错误: 找不到注册表项"SOFTWAREMicrosoftMicrosoft SQL Server100ConfigurationState". 错误代码 0x84BB0001. 按钮: 确定 是因为安装sqlserver第一次没有安装成功,卸载了也没有完全卸载干净,然后安装sql server 2008 r2说注册表无法删除,我就按照网上的操作把

SQL Server 致程序员(容易忽略的错误)

原文:SQL Server 致程序员(容易忽略的错误) 标签:SQL SERVER/MSSQL/DBA/T-SQL好习惯/数据库/需要注意的地方/程序员/容易犯的错误/遇到的问题 概述 因为每天需要审核程序员发布的SQL语句,所以收集了一些程序员的一些常见问题,还有一些平时收集的其它一些问题,这也是很多人容易忽视的问题,在以后收集到的问题会补充在文章末尾,欢迎关注,由于收集的问题很多是针对于生产数据,测试且数据量比较大,这里就不把数据共享出来了,大家理解意思就行.   步骤 大小写 大写T-SQ

Sql Server如何查看被锁的表及解锁的方法_MsSql

查看被锁表: select spId from master..SysProcesses where db_Name(dbID) = '数据库名称' and spId <> @@SpId and dbID <> 0 解除锁: exec ('Kill '+cast(@spid as varchar)) 查看被锁表: select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName f