尝试插入数据时ConfigurationManager出错

时间:2017-03-03 15:20:01

标签: asp.net vb.net visual-studio

所以我试图将数据添加到MySQL服务器数据库。

以下是代码:

MSStickerBrowserView

当我插入数据并点击它显示的extension StickerBrowserViewController { override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int { return stickers.count } override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker { return stickers[index] } } 时出现以下错误:

Image of the error

1 个答案:

答案 0 :(得分:0)

所以我做了Bugs所说的并且它有效。

这是工作代码:

Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim conn As SqlConnection = New SqlConnection("Data Source=JOAOCOQUIM\SQLEXPRESS;Initial Catalog=Teste;Integrated Security=True")
        Dim connection As SqlConnection = New SqlConnection("Data Source=JOAOCOQUIM\SQLEXPRESS;Initial Catalog=Teste;Integrated Security=True")
        Dim sql As String = "Insert into [User] ([nome], [idade]) values (@nome, @idade)"
        Dim cmd As SqlCommand = New SqlCommand(sql, connection)
        cmd.Parameters.AddWithValue("@nome", TextBox1.Text)
        cmd.Parameters.AddWithValue("@idade", TextBox2.Text)


        connection.Open()
        cmd.ExecuteNonQuery()
        connection.Close()
    End Sub
End Class