为什么rs1.Open strSelect1,conn,adOpenStatic行,而rs1.Open strSelect1,conn,adOpenStatic,adLockOptimistic就不行

陈小弟110 2003-03-11 11:36:32
RT
...全文
47 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
陈小弟110 2003-03-12
  • 打赏
  • 举报
回复
谢谢了
我的问题解决了
逍遥小贼 2003-03-11
  • 打赏
  • 举报
回复
我觉得是你的常量定义的问题,你的定义(或者定义文件)中是否定义了
Const adLockOptimistic
逍遥小贼 2003-03-11
  • 打赏
  • 举报
回复
<%
'定义数据库连接的一些常量
Const adOpenForwardOnly = 0 '(默认值)游标只向前浏览记录,不支持分页、Recordset、BookMark
Const adOpenKeyset = 1 '键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark
Const adOpenDynamic = 2 '动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。
Const adOpenStatic = 3 '静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动

Const adLockReadOnly = 1 '(默认值)锁定类型,默认的,只读,不能作任何修改
Const adLockPessimistic = 2 '当编辑时立即锁定记录,最安全的方式
Const adLockOptimistic = 3 '只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等
Const adLockBatchOptimistic = 4 '当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的

Const adCmdText = &H0001
Const adCmdTable = &H0002
%>

Open 方法 (ADO Recordset)


打开游标。

语法

recordset.Open Source, ActiveConnection, CursorType, LockType, Options
using System; using System.Data; using System.Data.SqlClient; using System.Collections; namespace mobilesale { /// /// DataBL 的摘要说明。 /// public class DataBL { public DataBL() { // // TODO: 在此处添加构造函数逻辑 // } public static SqlConnection getConn() { SqlConnection sqlCon= new SqlConnection("server=.;Integrated Security=SSPI;Database=MTSSystem"); return sqlCon; } public static DataTable selectMobile() { SqlConnection con=DataBL.getConn(); String strSelect="select mobileModelID as '手机编号',mobileModel as '手机型号',mobileFactory as '手机厂家',totalPrice as '手机全价',maxDisccunt as '最大折扣' from mobileModel"; SqlDataAdapter adapter=new SqlDataAdapter(strSelect,con); DataTable tab=new DataTable(); adapter.Fill(tab); return tab; } public static DataTable selectSales() { SqlConnection con=DataBL.getConn(); String strSelect="select saleID as '营业员编号',saleName as '姓名',salesVolume as '销售额' from mobileSales"; SqlDataAdapter adapter=new SqlDataAdapter(strSelect,con); DataTable tab=new DataTable(); adapter.Fill(tab); return tab; } public static ArrayList selectSaleNames() { SqlConnection con=DataBL.getConn(); String strSelect="select saleName as '姓名'from mobileSales"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); SqlDataReader reader=cmd.ExecuteReader(); ArrayList data=new ArrayList(); while(reader.Read()) { data.Add(reader.GetString(0)); } con.Close(); return data; } public static ArrayList selectMobileModel() { SqlConnection con=DataBL.getConn(); String strSelect="select mobileModel as '手机型号'from mobileModel"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); SqlDataReader reader=cmd.ExecuteReader(); ArrayList data=new ArrayList(); while(reader.Read()) { data.Add(reader.GetValue(0)); } con.Close(); return data; } public static ArrayList selectDisccunt(string mobileModel) { SqlConnection con=DataBL.getConn(); String strSelect="select maxDisccunt from mobileModel where mobileModel='"+mobileModel+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int maxDisccunt=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); ArrayList data=new ArrayList(); for(int i=maxDisccunt;i<=100;i++) { data.Add(i); } return data; } public static String setPrice(string mobileModel,string count,string disccunt) { SqlConnection con=DataBL.getConn(); String strSelect="select totalprice from mobileModel where mobileModel='"+mobileModel+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int maxDisccunt=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); return (maxDisccunt*Int32.Parse(count)*Int32.Parse(disccunt)/100).ToString(); } public static int insertOrder(string saleName,string mobileModel,string customer,string IDCardNo,string amount ,string price) { SqlConnection con=DataBL.getConn(); String strSelect="select saleID from mobileSales where saleName='"+saleName+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int saleId=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); strSelect="select mobileModelID from mobileModel where mobileModel='"+mobileModel+"'"; cmd=new SqlCommand(strSelect,con); con.Open(); int mobileModelID=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); string strInsert ="insert into mobileOrder values ('"+customer+"','"+IDCardNo+"',"+saleId+","+mobileModelID+","+Int32.Parse(amount)+","+Int32.Parse(price)+",'"+DateTime.Now.ToString()+"')"; cmd=new SqlCommand(strInsert,con); con.Open(); return cmd.ExecuteNonQuery(); con.Close(); } } }
JS三级联动表单

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧