使用SQL插入表格时出错

您所在的位置:网站首页 附加数据库时出错 使用SQL插入表格时出错

使用SQL插入表格时出错

2023-03-04 17:48| 来源: 网络整理| 查看: 265

如果这是一个重复的问题,我道歉,但我似乎无法找到我的特定问题.根据我的错误,我知道我的INSERT语句中的变量没有被分配,但是我发现的每个其他示例都显示哪个变量有问题,而且我的问题,似乎没有变量获得值?

private void insertListIntoSQL(List authList) { string connectionstring; //Connection String Info SqlConnection cnn = new SqlConnection(connectionstring); cnn.Open(); authList.RemoveAt(0); foreach(string[] auth in authList) { SqlCommand updateTable = new SqlCommand("INSERT INTO AuthSubmitAppLog (RECEIVED, STATUS_COMMENTS, AUTHORIZATION_NUMBER, CASE_MANAGER, ENTER_DATE, UPDATE_DATE, COMPLETED_BY, COMPLETED_DATETIME, CONTRACT_ENROLL_DATE, CONTRACT_DISENROLL_DATE, DIAGNOSIS_CODE, AUTHORIZATION_TYPE, AUTHORIZATION_TYPE_DETAIL, MEMBER_NAME, MEMBER_ID, MEMBERSHIP_ID, MEMBER_ADDRESS_1, MEMBER_ADDRESS_2, MEMBER_CITY, MEMBER_STATE, MEMBER_ZIP, REGION, MEMBER_PHONE, LINE_OF_BUSINESS, MEDICAID_NUMBER, MEDICARE_NUMBER, MEDICARE_TYPE, VENDOR_NAME, MCO_PROVIDER_NAME, LOCATION_ID, EFFECTIVE_DATE, EXPIRATION_DATE, SERVICE_CATEGORY, DETAIL_NUMBERS, SERVICE_CODE, MODIFIER_1, MODIFIER_2, MODIFIER_3, MODIFIER_4, SUNDAY_UNITS, MONDAY_UNITS, TUESDAY_UNITS, WEDNESDAY_UNITS, THURSDAY_UNITS, FRIDAY_UNITS, SATURDAY_UNITS, TOTAL_UNITS, NOTES_TO_PROVIDER, CASE_TYPE, STATUS, ALTERNATIVE_CASE_NUMBERS, SERVICES_CT_ID) VALUES (@RECEIVED, @STATUS_COMMENTS, @AUTHORIZATION_NUMBER, @CASE_MANAGER, @ENTER_DATE, @UPDATE_DATE, @COMPLETED_BY, @COMPLETED_DATETIME, @CONTRACT_ENROLL_DATE, @CONTRACT_DISENROLL_DATE, @DIAGNOSIS_CODE, @AUTHORIZATION_TYPE, @AUTHORIZATION_TYPE_DETAIL, @MEMBER_NAME, @MEMBER_ID, @MEMBERSHIP_ID, @MEMBER_ADDRESS_1, @MEMBER_ADDRESS_2, @MEMBER_CITY, @MEMBER_STATE,@ MEMBER_ZIP, @REGION, @MEMBER_PHONE, @LINE_OF_BUSINESS, @MEDICAID_NUMBER, @MEDICARE_NUMBER, @MEDICARE_TYPE, @VENDOR_NAME, @MCO_PROVIDER_NAME, @LOCATION_ID, @EFFECTIVE_DATE, @EXPIRATION_DATE, @SERVICE_CATEGORY, @DETAIL_NUMBERS, @SERVICE_CODE, @MODIFIER_1, @MODIFIER_2, @MODIFIER_3, @MODIFIER_4, @SUNDAY_UNITS, @MONDAY_UNITS, @TUESDAY_UNITS, @WEDNESDAY_UNITS, @THURSDAY_UNITS, @FRIDAY_UNITS, @SATURDAY_UNITS, @TOTAL_UNITS, @NOTES_TO_PROVIDER, @CASE_TYPE, @STATUS, @ALTERNATIVE_CASE_NUMBERS, @SERVICES_CT_ID)"); updateTable.COnnection= cnn; updateTable.Parameters.AddWithValue("@RECEIVED", SqlDbType.VarChar).Value = auth[0].Normalize(); updateTable.Parameters.AddWithValue("@STATUS_COMMENTS", SqlDbType.VarChar).Value = auth[1].Normalize(); updateTable.Parameters.AddWithValue("@AUTHORIZATION_NUMBER", SqlDbType.VarChar).Value = auth[2].Normalize(); updateTable.Parameters.AddWithValue("@CASE_MANAGER", SqlDbType.VarChar).Value = auth[3].Normalize(); updateTable.Parameters.AddWithValue("@ENTER_DATE", SqlDbType.DateTime).Value = Convert.ToDateTime(auth[4]).ToString().Normalize(); updateTable.Parameters.AddWithValue("@UPDATE_DATE", SqlDbType.DateTime).Value = Convert.ToDateTime(auth[5]).ToString().Normalize(); updateTable.Parameters.AddWithValue("@COMPLETED_BY", SqlDbType.VarChar).Value = auth[6].Normalize(); updateTable.Parameters.AddWithValue("@COMPLETED_DATETIME", SqlDbType.DateTime).Value = auth[7].Normalize(); updateTable.Parameters.AddWithValue("@CONTRACT_ENROLL_DATE", SqlDbType.DateTime).Value = Convert.ToDateTime(auth[8]).ToString().Normalize(); updateTable.Parameters.AddWithValue("@CONTRACT_DISENROLL_DATE", SqlDbType.DateTime).Value = Convert.ToDateTime(auth[9]).ToString().Normalize(); updateTable.Parameters.AddWithValue("@DIAGNOSIS_CODE", SqlDbType.VarChar).Value = auth[10].Normalize(); updateTable.Parameters.AddWithValue("@AUTHORIZATION_TYPE", SqlDbType.VarChar).Value = auth[11].Normalize(); updateTable.Parameters.AddWithValue("@AUTHORIZATION_TYPE_DETAIL", SqlDbType.VarChar).Value = auth[12].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_NAME", SqlDbType.VarChar).Value = auth[13].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_ID", SqlDbType.VarChar).Value = auth[14].Normalize(); updateTable.Parameters.AddWithValue("@MEMBERSHIP_ID", SqlDbType.VarChar).Value = auth[15].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_ADDRESS_1", SqlDbType.VarChar).Value = auth[16].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_ADDRESS_2", SqlDbType.VarChar).Value = auth[17].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_CITY", SqlDbType.VarChar).Value = auth[18].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_STATE", SqlDbType.VarChar).Value = auth[19].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_ZIP", SqlDbType.VarChar).Value = auth[20].Normalize(); updateTable.Parameters.AddWithValue("@REGION", SqlDbType.VarChar).Value = auth[21].Normalize(); updateTable.Parameters.AddWithValue("@MEMBER_PHONE", SqlDbType.VarChar).Value = auth[22].Normalize(); updateTable.Parameters.AddWithValue("@LINE_OF_BUSINESS", SqlDbType.VarChar).Value = auth[23].Normalize(); updateTable.Parameters.AddWithValue("@MEDICAID_NUMBER", SqlDbType.VarChar).Value = auth[24].Normalize(); updateTable.Parameters.AddWithValue("@MEDICARE_NUMBER", SqlDbType.VarChar).Value = auth[25].Normalize(); updateTable.Parameters.AddWithValue("@MEDICARE_TYPE", SqlDbType.VarChar).Value = auth[26].Normalize(); updateTable.Parameters.AddWithValue("@VENDOR_NAME", SqlDbType.VarChar).Value = auth[27].Normalize(); updateTable.Parameters.AddWithValue("@MCO_PROVIDER_NAME", SqlDbType.VarChar).Value = auth[28].Normalize(); updateTable.Parameters.AddWithValue("@LOCATION_ID", SqlDbType.VarChar).Value = auth[29].Normalize(); updateTable.Parameters.AddWithValue("@EFFECTIVE_DATE", SqlDbType.DateTime).Value = auth[30].Normalize(); updateTable.Parameters.AddWithValue("@EXPIRATION_DATE", SqlDbType.DateTime).Value = auth[31].Normalize(); updateTable.Parameters.AddWithValue("@SERVICE_CATEGORY", SqlDbType.VarChar).Value = auth[32].Normalize(); updateTable.Parameters.AddWithValue("@DETAIL_NUMBERS", SqlDbType.VarChar).Value = auth[33].Normalize(); updateTable.Parameters.AddWithValue("@SERVICE_CODE", SqlDbType.VarChar).Value = auth[34].Normalize(); updateTable.Parameters.AddWithValue("@MODIFIER_1", SqlDbType.VarChar).Value = auth[35].Normalize(); updateTable.Parameters.AddWithValue("@MODIFIER_2", SqlDbType.VarChar).Value = auth[36].Normalize(); updateTable.Parameters.AddWithValue("@MODIFIER_3", SqlDbType.VarChar).Value = auth[37].Normalize(); updateTable.Parameters.AddWithValue("@MODIFIER_4", SqlDbType.VarChar).Value = auth[38].Normalize(); updateTable.Parameters.AddWithValue("@SUNDAY_UNITS", SqlDbType.VarChar).Value = auth[39].Normalize(); updateTable.Parameters.AddWithValue("@MONDAY_UNITS", SqlDbType.VarChar).Value = auth[40].Normalize(); updateTable.Parameters.AddWithValue("@TUESDAY_UNITS", SqlDbType.VarChar).Value = auth[41].Normalize(); updateTable.Parameters.AddWithValue("@WEDNESDAY_UNITS", SqlDbType.VarChar).Value = auth[42].Normalize(); updateTable.Parameters.AddWithValue("@THURSDAY_UNITS", SqlDbType.VarChar).Value = auth[43].Normalize(); updateTable.Parameters.AddWithValue("@FRIDAY_UNITS", SqlDbType.VarChar).Value = auth[44].Normalize(); updateTable.Parameters.AddWithValue("@SATURDAY_UNITS", SqlDbType.VarChar).Value = auth[45].Normalize(); updateTable.Parameters.AddWithValue("@TOTAL_UNITS", SqlDbType.VarChar).Value = auth[46].Normalize(); updateTable.Parameters.AddWithValue("@NOTES_TO_PROVIDER", SqlDbType.VarChar).Value = auth[47].Normalize(); updateTable.Parameters.AddWithValue("@STATUS", SqlDbType.VarChar).Value = auth[48].Normalize(); updateTable.Parameters.AddWithValue("@CASE_TYPE", SqlDbType.VarChar).Value = auth[49].Normalize(); updateTable.Parameters.AddWithValue("@ALTERNATIVE_CASE_NUMBERS", SqlDbType.VarChar).Value = auth[50].Normalize(); updateTable.Parameters.AddWithValue("@SERVICES_CT_ID", SqlDbType.VarChar).Value = auth[51].Normalize(); updateTable.ExecuteNonQuery(); //

我调用updateTable.ExecuteNonQuery(); 我收到此错误:

System.Data.dll中出现"System.Data.SqlClient.SqlException"类型的异常,但未在用户代码中处理

附加信息:必须声明标量变量"@".

哪个不允许我真正弄清楚问题是什么,任何人都可以推荐我应该修复的内容吗?谢谢!

1> 小智..:

您在@ MEMBER_ZIP有空格



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3