为什么,有异常??

问题描述

try{//连接数据库SqlConnectioncon=DB.connection();SqlCommandcom=con.CreateCommand();com.CommandText="updatehotel_infoseth_name=@namehotel,h_tel=@tel,h_address=@address";SqlParameterpara0=newSqlParameter("@name",SqlDbType.VarChar,50);para0.Value=hotel.hotel_name;com.Parameters.Add(para0);SqlParameterpara1=newSqlParameter("@tel",SqlDbType.VarChar,50);para1.Value=hotel.hotel_tel;com.Parameters.Add(para1);SqlParameterpara2=newSqlParameter("@address",SqlDbType.VarChar,50);para2.Value=hotel.hotel_address;com.Parameters.Add(para2);com.ExecuteNonQuery();con.Close();returntrue;}catch(Exceptione){returnfalse;}我想用这段代码来修改数据库中的信息,但是,运行起来会跳出异常

解决方案

解决方案二:
updatehotel_infoseth_name=@name**hotel,h_tel=@tel,h_address=@address";
解决方案三:
para0.Value=hotel.hotel_name;//这里是?"updatehotel_infoseth_name=@namehotel,h_tel=@tel,h_address=@address";//这里明显有错误

解决方案四:
你update语句没有条件啊
解决方案五:
try{//连接数据库SqlConnectioncon=DB.connection();SqlCommandcom=con.CreateCommand();com.CommandText="updatehotel_infoseth_name=@name,h_tel=@tel,h_address=@address";SqlParameterpara0=newSqlParameter("@name",SqlDbType.VarChar,50);para0.Value="11111";com.Parameters.Add(para0);SqlParameterpara1=newSqlParameter("@tel",SqlDbType.VarChar,50);para1.Value="22222";com.Parameters.Add(para1);SqlParameterpara2=newSqlParameter("@address",SqlDbType.VarChar,50);para2.Value="3333";com.Parameters.Add(para2);com.ExecuteNonQuery();con.Close();returntrue;}catch(Exceptione){returnfalse;}这看看应该没错了

时间: 2024-08-01 15:48:32

为什么,有异常??的相关文章

process-Widget启动报异常。请求解决

问题描述 Widget启动报异常.请求解决 Unable to launch app or broadcast Intent process is bad act=android.appwidget.action.APPWIDGET_ENABLED 怎么回事啊!!! 开始还好好的,后来不晓得怎么了,装widget一直报这个错,不晓得抽什么风, 网上说神马卸掉重装,卸掉关机重启重装,统统都不行.... 解决方案 http://stackoverflow.com/questions/3253676/

处理The content of the adapter has changed but ListView did not receive a notification异常

istView在更新时报异常: ERROR/AndroidRuntime(15260): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only

ef 通过DbCommandInterceptor 修改数据库连接 添加数据异常

问题描述 ef 通过DbCommandInterceptor 修改数据库连接 添加数据异常 我想实现数据库的读写分离 ef6里面加了DbCommandInterceptor的功能可是修改以后 在添加新数据的时候 抛出异常 "基础提供程序在 Commit 上失败 值不能为 null. 参数名: connection"但是数据已经成功添加那位前辈读到过这个问题呢 请指导 public class EntityCommandInterceptor: DbCommandInterceptor

tomcat启动的问题,报异常

问题描述 tomcat启动的问题,报异常 解决方案 和tomcat没关系.是你web.xml中的配置的servlet加载的时候报错了 解决方案二: 采用flex+struts+spring+hibernate框架,启动tomcat出现异常,寻求解决方法中..... 严重: StandardWrapper.Throwablejava.lang.NullPointerException?at flex.management.BaseControl.getObjectName(BaseControl.

tomcat启动报错-eclipse 启动 tomcat 异常

问题描述 eclipse 启动 tomcat 异常 tomcat: apache-tomcat-7.0.54-windows-x86 绿色版 eclipse: eclipse-jee-luna-R-win32 . eclipse-jee-indigo-SR2-win32 直接在 ${TOMCAT_HOME}/bin 下双击 startup.bat 可以正常启动,无任何问题, 但是在 eclipse 中配置好之后,加入web工程,启动tomcat,就出现了下面的错误信息: Error occurr

myeclipse配置了weblogic,启动服务报异常

问题描述 myeclipse配置了weblogic,启动服务报异常 1C 解决方案 认证没有通过,估计是myeclipse配置weblogic,忘了设置 解决方案二: weblogic用户名密码不对~

使用osgi api启动osgi时,用java -jar命令运行报异常,用eclipse运行正常

问题描述 使用osgi api启动osgi时,用java -jar命令运行报异常,用eclipse运行正常 我使用osgi的api写了osgi框架的启动程序,然后使用java -jar 命令运行这个jar包报空指针异常,我在eclipse中运行一切正常,请问这是为什么呀

java-myeclipse10配置jrebel6因为改动电脑日期报异常

问题描述 myeclipse10配置jrebel6因为改动电脑日期报异常 运行环境:myeclipse10配置jrebel6 问题原因:在myeclise10的tomcat7的jdk下Optional java VM arguments配置上jrebel后加入,在电脑日期是今天2015.10.21下启动tomcat,能正常启动,但是假如电脑日期把今天改为2015.10.06启动tomcat就会抛出一个异常: if (!fromStart && !toEnd) { if (m.compare

java 连接异常-java 启动jdbc 事务报错 嵌套异常

问题描述 java 启动jdbc 事务报错 嵌套异常 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC

分享一个异步任务在遇到IO异常时支持递归回调的辅助方法

public void TryAsyncActionRecursively<TAsyncResult>( string asyncActionName, Func<Task<TAsyncResult>> asyncAction, Action<int> mainAction, Action<TAsyncResult> successAction, Func<string> getContextInfoFunc, Action<E