帮忙改正一下代码,急!
有一段数据提交页面的代码,想提交时同时将数据更新和插入到两台服务器的不同数据库和不同数据表中,现在更新可以,但插入不行.Dim mFieldsStr As String
Dim mValuesStr As String
Dim mSql As String
Dim dmssql As String '插入DMS工程文件DOC2的SQL语句
If Me.IsValid = False Then
Exit Sub
End If
mSql = "update component set controlno='" + tControlNo.Text.Trim.ToUpper + "', auditname='" + tUserId.Text.Trim + "', auditdate='" + tDate.Text + "' ,state='生效',ReturnInfo='待审核' where id=" + tID.Text
Dim mCn As SqlClient.SqlConnection
Dim mCmd As SqlClient.SqlCommand
mCn = New SqlClient.SqlConnection("workstation id=ZHANG;packet size=4096;user id=sa;password=123;data source=WEB;persist security info=False;initial catalog=EDC")
mCmd = New SqlClient.SqlCommand
mCmd.Connection = mCn
mCmd.CommandType = CommandType.Text
mCmd.CommandText = mSql
mCn.Open()
mCmd.ExecuteNonQuery()
mCn.Close()
mCmd = Nothing
'在此增加语句插入对DMS进行操作
mFieldsStr = "control_no,issue_date,rev,p_n,pages,name,IssueBy"
mValuesStr = "'" + tControlNo.Text.Trim.ToUpper + "','" + tDate.Text + "','" + tRev.Text.Trim + "','" + tPartNum.Text.Trim + "','" + tPages.Text.Trim + "','" + tPartDesc.Text.Trim + "','" + tWriteBy.Text.Trim + "'"
dmssql = "insert into doc2 (" + mFieldsStr + ") values(" + mValuesStr + ")"
Dim nCn As SqlClient.SqlConnection
Dim nCmd As SqlClient.SqlCommand
nCn = New SqlClient.SqlConnection("workstation id=HEN;packet size=4096;user id=sa;password=123;data source=SVR;persist security info=False;initial catalog=Doc")
nCmd = New SqlClient.SqlCommand
nCmd.Connection = nCn
nCmd.CommandType = CommandType.Text
nCmd.CommandText = dmssql
nCn.Open()
nCmd.ExecuteNonQuery()
nCn.Close()
nCmd = Nothing
Response.Write("审核成功!")
Response.End()
End Sub --------------------编程问答--------------------
补充:.NET技术 , ASP.NET