VB.NET INSERT时ExecuteNonQuery: Connection 属性尚未初始化 10
Sqlcn5.ConnectionString="Server="&ServerIP&";Database=HUAX;Uid=sa;Pwd=123;"IfSqlcn5.S...
Sqlcn5.ConnectionString = "Server=" & ServerIP & ";Database=HUAX;Uid=sa;Pwd=123;"
If Sqlcn5.State = True Then Sqlcn5.Close()
Sqlcd5.CommandText = "INSERT INTO Mt " & _
"(destination,[content],userSendDate)" & _
"VALUES(@destination,@[content],@userSendDate)"
Sqlcd5.Parameters.AddWithValue("@destination", TextBox1.Text)
Sqlcd5.Parameters.AddWithValue("@[content]", TextBox2.Text)
Sqlcd5.Parameters.AddWithValue("@userSendDate", Now.ToString)
Sqlcn5.Open() '打开连接
Dim EfectRows As Integer = Sqlcd5.ExecuteNonQuery() '执行操作并将影响的行数赋给变量
Sqlcn5.Close() '关闭连接
当执行到Sqlcd5.ExecuteNonQuery() 时便报错了,搜了很多资料都没有解决。 展开
If Sqlcn5.State = True Then Sqlcn5.Close()
Sqlcd5.CommandText = "INSERT INTO Mt " & _
"(destination,[content],userSendDate)" & _
"VALUES(@destination,@[content],@userSendDate)"
Sqlcd5.Parameters.AddWithValue("@destination", TextBox1.Text)
Sqlcd5.Parameters.AddWithValue("@[content]", TextBox2.Text)
Sqlcd5.Parameters.AddWithValue("@userSendDate", Now.ToString)
Sqlcn5.Open() '打开连接
Dim EfectRows As Integer = Sqlcd5.ExecuteNonQuery() '执行操作并将影响的行数赋给变量
Sqlcn5.Close() '关闭连接
当执行到Sqlcd5.ExecuteNonQuery() 时便报错了,搜了很多资料都没有解决。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询