zoukankan      html  css  js  c++  java
  • DLL version issue and SQL Parameters Issue

    1. 在工程中Reference dll: 

       1).specify version: true or false should be same.Other wise, there will be conflick between these dlls expecily that have depence.

       2). We can set all of them are true or all false.

    2.SqlException: The parameterized query ## expects the pa... RSS

    Resolved.

            
    public void UpdateTableInfo(string command, string dbTableName, DataTable dataTable, IList<string> parameters) 
            { 
                _dataAdapter.InsertCommand 
    = new SqlCommand(@command); 
                IList tableColumnTypes 
    = GetTableColumnTypes(dbTableName); 
                
    for (int i = 0; i < parameters.Count; i++
                { 
                    _dataAdapter.InsertCommand.Parameters.Add(
    new SqlParameter("@" + parameters[i], tableColumnTypes[i])); 
                    _dataAdapter.InsertCommand.Parameters[
    "@" + parameters[i]].SourceVersion = DataRowVersion.Current; 
                    _dataAdapter.InsertCommand.Parameters[
    "@" + parameters[i]].SourceColumn = dataTable.Columns[i].ColumnName; 
                } 
                SqlConnection conn 
    = DbConnection; 
                _dataAdapter.InsertCommand.Connection 
    = conn; 
                
    using (conn) 
                { 
                    _dataAdapter.Update(dataTable.DataSet, dbTableName); 
                } 
            }

    I'm wondering if my problem possibly has to do with null or empty values in my DataTable ("dataTable"). The exception error seems to imply that a parameter value was not supplied in the parameterized query? Like the value of @Value0 was empty or null in my DataTable (for a particular row)?

    If this is the case, how can I handle empty or null values in my DataTable so that this problem does not arise? Insert a DbNull value into my database for each empty or null value in the DataTable? How might that be best accomplished? I guess I would have to allow NULL values in my database table to do this?

    做个快乐的自己。
  • 相关阅读:
    Mysql 数据库优化(五)sql语句优化【个人经验】转
    C# 编写的winform程序的托盘功能
    Mysql 数据库‘’函数‘、‘’事件‘’完成时间字段自动更新
    dd
    c# ‘using’三种用法
    集群、分布式、负载均衡
    iOS开发- Xcode 7添加pch文件
    iOS开发-pod install 出错 The dependency `AFNetworking (~> 2.6.0)` is not used in any concrete target.
    leetcode -- Find Median from Data Stream
    ubuntu14.04 LTS 更新源
  • 原文地址:https://www.cnblogs.com/Jessy/p/2068552.html
Copyright © 2011-2022 走看看