asp向access数据库中添加数据,添加成功但是表格中只是增加了一行并没有内容
If(CStr(Request("MM_insert"))="form1")ThenMM_editConnection=MM_cnn_STRINGMM_editTable...
If (CStr(Request("MM_insert")) = "form1") Then
MM_editConnection = MM_cnn_STRING
MM_editTable = "[user]"
MM_editRedirectUrl = "right.asp"
MM_fieldsStr = "[username]|value|[password]|value"
MM_columnsStr = "[username]|',none,''|[password]|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl) 展开
MM_editConnection = MM_cnn_STRING
MM_editTable = "[user]"
MM_editRedirectUrl = "right.asp"
MM_fieldsStr = "[username]|value|[password]|value"
MM_columnsStr = "[username]|',none,''|[password]|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl) 展开
3个回答
展开全部
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
上面这句是插入查询的SQL语句,其中MM_editTable是要插入记录的表名,前面有赋值,MM_tableValues是字段名,MM_dbValues是各字段对应的值,这两个变量均未被赋值
题主看出端倪了吗?
上面这句是插入查询的SQL语句,其中MM_editTable是要插入记录的表名,前面有赋值,MM_tableValues是字段名,MM_dbValues是各字段对应的值,这两个变量均未被赋值
题主看出端倪了吗?
更多追问追答
追答
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
在这句后加下面两行代码进行调试:
response.write MM_editQuery '在页面上显示出生成的SQL语句
response.end '停止执行后面的代码
你将调试时生成的SQL检查下,看是否有问题,可以复制到access中生成一个新查询运行试试看。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询