Dim ck_mxquot As New SqlCommand
Dim t_id as Integer
ck_mxquot.Connection = sql_conn
ck_mxquot.CommandText = "select max(propid) from tb1"
sql_conn.Open()
Dim objckmx As Object = ck_mxquot.ExecuteScalar
sql_conn.Close()
If objckmx Is DBNull.Value Then
t_id=1
Else
Dim mx As Integer = CType(objckmx, Integer )
t_id =mx+1
End If
'插入数据
Dim add_m As New SqlCommand
add_m.Connection = sql_conn
add_m.CommandText = "insert into tb1(propid,id_loginid) values(@propid,@id_xx)"
add_m.Parameters.AddWithValue("@propid", t_id)
add_m.Parameters.AddWithValue("@id_xx", "admin")
sql_conn.Open()
add_m.ExecuteNonQuery()
sql_conn.Close()
追问这样写有错吗??
不知道为什麼运行後出现ExecuteScalar: Connection 属性尚未初始化。的提示..
采纳错了 不好意思 已经开了新提问 希望你能继续帮帮我…
连结在这
http://zhidao.baidu.com/question/456987766706408205.html
请问可以帮帮我吗?昨天问题采纳错人了 希望你继续帮我解决昨天未解决的问题
来自:求助得到的回答