vb.net中的连接字符串错误

时间:2014-02-22 06:07:32

标签: vb.net string connection

受尊敬的用户我面临在vb.net中插入数据库记录的问题,但是我使用的代码不在这里。

 Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\Users\abcd\Documents\Visual Studio 2010\WebSites\WebSite1\App_Data\Database.mdf"";Integrated Security=True;User Instance=True"
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "insert into snapdata (uid,ppath,desc) values (147,'hello','bye')"
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(" Error while inserting record")
        Finally
            con.Close()
        End Try

但它在catch块中。我也在数据库路径中尝试了“\\”而不是“\”,但它不起作用。请帮忙

0 个答案:

没有答案