不支持关键字:“SSL 模式”,在 VB.Net GridView 中设置连接字符串时

not supported keyword: "SSL Mode" while setting up connection string in VB.Net GridView

提问人:Adele 提问时间:11/7/2023 最后编辑:CraigAdele 更新时间:11/7/2023 访问量:21

问:

因此,我在 Vb.Net 中创建了一个 GridView,目标是在 GridView 的脚行中向 SQL 数据库插入新行。 当我尝试实际插入新行并单击“插入”按钮时,它出现错误:

不支持关键字:“SSL 模式”

我做错了什么?

这是我的代码:

Protected Sub SUBINSERT(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged

    For Each row As GridViewRow In GridView1.Rows
        Dim constring As String = "server=localhost;user id=root;Password=;database=NAME;sslMode=None;Convert Zero Datetime=True"
        Dim FooterRow As GridViewRow = CType(GridView1.FooterRow, GridViewRow)
        Dim strCustomerID As String = TryCast(FooterRow.FindControl("ddlCustomerID"), DropDownList).SelectedValue
        Dim strOrderID As String = TryCast(FooterRow.FindControl("textboxOrderID"), TextBox).Text
        Dim strOrderDate As String = TryCast(FooterRow.FindControl("textboxOrderDate"), TextBox).Text
        Dim strOrderTotal As String = TryCast(FooterRow.FindControl("textboxOrderTotal"), TextBox).Text



        Using con As New SqlConnection(constring)
            Using cmd As New SqlCommand("INSERT into Orders(OrderID,OrderDate,CustomerID,OrderTotal),Values(@OrderID,@OrderDate,@CustomerID,@OrderTotal)", con)

                cmd.Parameters.AddWithValue("@OrderID", strOrderID)
                cmd.Parameters.AddWithValue("@OrderDate", strOrderDate)
                cmd.Parameters.AddWithValue("@CustomerID", strCustomerID)
                cmd.Parameters.AddWithValue("@OrderTotal", strOrderTotal)

                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using

    Next
    MsgBox("Inserted successfully")

End Sub
asp.net vb.net GridView WebForms 连接字符串

评论

1赞 jmcilhinney 11/7/2023
看起来您正在尝试将 MySQL 连接字符串用于 SQL Server。首先,确保您知道实际使用的数据库,并且您正在为它使用正确的 ADO.NET 提供程序。接下来,转到此处查找相应的连接字符串格式。

答: 暂无答案