标题:怎样连接数据库
只看楼主
秋意
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-8-25
结帖率:0
已结贴  问题点数:20 回复次数:2 
怎样连接数据库
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/ljsjk.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject (")
    MM_editCmd.ActiveConnection = MM_ljsjk_STRING
    MM_ = "INSERT INTO [user] ([username], mima, dizi, zname, tel) VALUES (?, ?, ?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 10, Request.Form("hname")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 10, Request.Form("pass1")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 100, Request.Form("add")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 201, 1, 20, Request.Form("zname")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 20, Request.Form("tel")) ' adLongVarChar
    MM_editCmd.Execute请问错在哪里
搜索更多相关主题的帖子: 连接数据库 Request include insert record 
2016-08-25 13:25
stave_7
Rank: 4
等 级:业余侠客
威 望:1
帖 子:36
专家分:227
注 册:2016-6-3
得分:20 
VB的看不懂

学习是大事
2016-08-25 14:10
qq12414333
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-12-8
得分:0 
vs...

string ConnectionString = "Integrated Security=True;Data Source=.;Initial Catalog=...;";
      
   SqlConnection conn = new SqlConnection(ConnectionString);
      
    conn.Open();
        
            int count = 0;
            
         string sql = string.Format("select count (*) from 学生 where 学号 ='{0}' and 登录密码 ='{1}'", Username, Userpass);
            
         SqlCommand cmd = new SqlCommand(sql, conn);
           
         count = (int)cmd.ExecuteScalar();
2016-12-08 15:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-468177-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.136786 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved