gpt4 book ai didi

mysql - 我的 SQL 在不应该 O.o 的情况下转换为 Int

转载 作者:行者123 更新时间:2023-11-30 00:47:40 25 4
gpt4 key购买 nike

好的,我在从程序更新 SQL 记录时收到以下错误:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Conversion failed when converting the nvarchar value 'Full Member' to data type int.

这是更新代码; (我已经标记了引用包含 TEXT 的文本框的两个点,但无缘无故地试图转换为 INT。

Public Class EditSelected
Dim con As SqlConnection
Dim stcon As String
Dim cmd As SqlCommand
Dim ds As DataSet
Dim da As SqlDataAdapter

.

Private Sub EditSelected_Load(sender As Object, e As EventArgs) Handles MyBase.Load    
stcon = "{Censored Connection String}"
con = New SqlConnection(stcon)

con.Open()


cmd = New SqlCommand("UPDATE PersonsA SET Members_ID=@id, Gamer_Tag=@gt, " & _
"Screenname=@screen, First_Name=@first, Last_Name=@last, DoB=@dob," & _
"E_Mail_Address=@email, Position=@pos, U_G_Studio=@ustudio, Cautions=@caution," & _
"Record=@record, Event_Attendance=@event, Member_Status=@memstatus, " & _ '<---ERROR HERE
"GTA_V_Crew_Member=@gtva, Games_Owned=@gameowned, Rep_Group=@repgroup " & _
"WHERE Members_ID=@id", con)

cmd.Parameters.AddWithValue("@id", midtxt.Text)
cmd.Parameters.AddWithValue("@gt", gttxt.Text)
cmd.Parameters.AddWithValue("@screen", sntxt.Text)
cmd.Parameters.AddWithValue("@first", fntxt.Text)
cmd.Parameters.AddWithValue("@last", lntxt.Text)
cmd.Parameters.AddWithValue("@dob", dobtxt.Text)
cmd.Parameters.AddWithValue("@email", emailtxt.Text)
cmd.Parameters.AddWithValue("@pos", teamptxt.Text)
cmd.Parameters.AddWithValue("@ustudio", ugptxt.Text)
cmd.Parameters.AddWithValue("@caution", ugctxt.Text)
cmd.Parameters.AddWithValue("@record", recordtxt.Text)
cmd.Parameters.AddWithValue("@event", eventatxt.Text)
cmd.Parameters.AddWithValue("@memstatus", memberstatcombo.Text) '<---ERROR HERE
cmd.Parameters.AddWithValue("@gtva", gtavcrewmembercombo.Text)
cmd.Parameters.AddWithValue("@gameowned", gamesownedtxt.Text)
cmd.Parameters.AddWithValue("@repgroup", RepGroupcombo.Text)
cmd.ExecuteNonQuery()
MsgBox("Data has been saved!")

da = New SqlDataAdapter("SELECT * FROM PersonsA", con)
ds = New DataSet
da.Fill(ds, "PersonsA")

LeadersAccessTable.DataGridView1.DataMember = "PersonsA"
LeadersAccessTable.DataGridView1.DataSource = ds

con.Close()

我的 SQL 列“Member_Status”的数据类型为 varchar(35) 并且可为空。

这是怎么回事;为什么它试图将其转换为整数?

{编辑1}

我提供了表列及其数据类型的屏幕截图 - 来自 SQL Management Studio 的屏幕截图。

Columns & File Names

最佳答案

糟糕,这取决于我的其他代码,它用所选索引的数据填充字段。事实证明,“正式成员”实际上并不在正确的文本框中,因此被发送到 INT 列之一。调试器应该更明显一点:/感谢您的帮助!

关于mysql - 我的 SQL 在不应该 O.o 的情况下转换为 Int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21223091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com