网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
请完善下列连接数据库的代码: string conStr="Data Source=(local);Initial Catalog=StudentSys;Integrated Security=True"; SqlConnection con = new SqlConnection(); con.Open();
参考答案和解析
连接池的基本思想是在系统初始化的时候,将数据库连接作为对象存储在内存中,当用户需要访问数据库时,并非建立一个新的连接,而是从内存的连接池中取出一个已建立的空闲连接对象。使用完毕后,用户也并非将关闭连接,而是将连接放回连接池中,以供下一个用户请求访问时使用。而连接的建立、断开都由连接池自身来管理。同时,还可以通过设置连接池的参数来控制连接池中的初始连接数、连接的上下限数以及每个连接的最大使用次数、最大空闲时间等等。也可以通过其自身的管理机制来监视数据库连接的数量、使用情况等。
更多 “请完善下列连接数据库的代码: string conStr="Data Source=(local);Initial Catalog=StudentSys;Integrated Security=True"; SqlConnection con = new SqlConnection(); con.Open();” 相关考题
考题
打开SQLConnection时返回的SQLServer错误号为4060,该错误表示()。A.连接字符串指定的服务器名称无效B.连接字符串指定的数据库名称无效C.连接超时D.连接字符串指定的用户名或密码错误
考题
oucreateapageinanASP.NETWebapplication.ThepageretrievesanddisplaysdatafromaMicrosoftSQLServerdatabase.Youneedtocreateadatasourcethatcanconnecttothedatabase.Whataretwopossiblewaystoachievethisgoal?()
A.UseanObjectDataSourcecontrolandsetitsTypeNamepropertyto System.Data.SqlClient.SqlConnection.B.UseaSqlDataSourcecontrolandconfigureitsConnectionStringintheweb.configfile.C.UseanXmlDataSourcecontroltogetherwithanXmlcontrolthatrepresentsthedatabase.D.UseaLinqDataSourcecontrolwithentityclassesthatrepresenttheelementsinthedatabase.
考题
下列代码的执行结果是( )。 public class Test{ public static void main String args[]){ String s1=new String("welcome"); String s2=new String("welcome"); System.out.println(s1==s2); System.out.println(s1.equals(s2)); } }A.false,falseB.false,trueC.true,trueD.true,false
考题
下列代码段的执行结果是( )。 public class Test { public static void main(String args[ ]) { String s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }A.true falseB.true trueC.false trueD.false false
考题
有如下代码段 public class OperatorAndExceptions { public static void main(String args[ ] { int i=10,j=15; System.out.println(i==j); String s1 = new String("how are you!"); String s2=new String("how are you!"); System.out.println(s1==s2); } } 其输出为( )。A.true falseB.true trueC.false trueD.false false
考题
下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }A.true, falseB.true, trueC.false, trueD.false, false
考题
某公司使用ASP.NET+SQL Server开发电子商务网站,该网站分为前台和后台两部分,前台具有会员登录、商品展示、商品搜索、个人中心和购物车等功能;后台具有商品管理、会员管理和订单管理等功能。5、ASP.NET访问数据库一般采用ADO.NET。ADO.NET主要包含Connection对象、Command对象、DataReader对象、DataAdapter对象、DataSet对象和DataView对象等。建立数据源连接使用的对象是______。连接对象创建完成后,打开连接,需使用的方法是______;连接对象使用结束后,一般需要关闭连接,使用的方法是______。如果在操作数据库时,需要大批量地处理数据或者想在断开数据库连接的情况下操作数据,.NET使用______对象将数据从数据库服务器中取出,并将数据存入______对象中。如果要添加、修改或删除数据,需要使用______对象。6、该电子商务网站数据库business中包含一张新闻表,名为news,结构如下表所示。
现在发现news表中缺少字段“新闻作者”,要求使用SQL语句添加该字段,字段名为newsauthor,数据类型为varchar,长度为20,默认值为admin。请根据题目说明,将SQL语句补充完整。ALTER TABLE ______ ADD ______ (20) default'______'.7、现要设计一个根据关键字搜索新闻及显示搜索结果的页面,页面包含的基本元素为:搜索关键字文本框,控件id为txtKeyword;搜索按钮,控件id为btnSearch;数据绑定显示控件gvNews。请根据题目说明,将空缺的代码补充完整。protected void btnsearch_Click(object sender,EventArgs e){String strcon="server='DBServer';database='business';uid='sa';pwd='sa';";Sqlconnection con=new sqlconnection(strcon);string keyword=this. ______.Text;string sqlstr="select*from news where ______ like '%"+keyword+"%'or ______ like '%"+keyword+"%'";try{SqlDataAdapter da=new sqlDataAdapter(______,con);DataSet ds=new DataSet();Da.Fill(______);gvNews.______=ds.Tables[0];gvNews.DataBind();}catch{ ?Response.write("无法连接数据库");}}
考题
"在连接数据库的过程中,数据库连接字符串为: Data Source=localhost; Initial Catalog= Haier; user id=sa; password=123456; Data Source代表什么含义:() Initial Catalog代表什么含义:() user id代表什么含义:() password代表什么含义:()"
考题
下列操作Session时,代码错误的是()A、HttpSession session=request.getSession(true);B、Session session=new Session();C、session.setAttribute("username","admin");D、String username=(String)session.getAttribute("username");E、response.add Session(Session);
考题
使用ADO连接到SQL Server数据库时有以下代码:%cn.open"Provider=sqloledb;Data Source=(local);Initial catalog=study Integrated Security=SSPI;"%表示其连接模式为()。A、信任模式B、安全模式C、正常模式D、普通模式
考题
以下关于连接字符串的描述中,正确的是()和()。A、Data Source属性表示数据库的类型B、Trusted_Connection参数决定连接是否使用信任连接C、Integrated Security参数决定连接是否使用信任连接D、Initial Catalog表示数据库的类型
考题
以下哪一种参数是设置非Windows集成安全下的数据库连接()。A、Trusted_Connection=YesB、use rid=sa;password=111C、Integrated Security=TrueD、Integrated Security=SSPI
考题
You are consuming a Windows Communication Foundation (WCF) service in an ASP. NET Web application.The service interface is defined as follows:[ServiceContract]public interface ICatalog{ [OperationContract] [WebGet(UriTemplate="/Catalog/Items/{id}", ResponseFormat=WebMessageFormat.Json)] string RetrieveItemDescription(int id); } The service is hosted at Catalogsvc.You need to call the service using jQuery to retrieve the description of an item as indicated by a variable named itemId. Which code segment should you use?()A、$get(String.format("/Catalogsvc/Catalog/Items/id{0}", itemId) null, function (data) { ... }, javascript");B、$get(String.format("/Catalogsvc/Catalog/Items/{0}", itemId), null, function (data) { ... }, "json");C、$get(String.format("/Catalogsvc/Catalog/Items/{0}", itemld), null, function (data) { ... }, "xml");D、$get(String.format("/Catalogsvc/Catalog/Items/id{0}", itemld), null, function (data) { ... }, "json");
考题
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application. The Contoso.com network contains a Microsoft SQL Server 2005 server named DB01. Your application retrieve records from a database named Trades that resides on DB01. The application connects to Trades by using an instance of the SqlConnection class with the following connection string. "Data Source=DB01;UID=’mhamm’;PWD=’password’;" When the application calls the Open method of the SqlConnection object, it displays the following: "Cannot open user default database. Login failed. Login failed for user ’mhamm’". You need to make sure that you can connect to Trades when the user account for the connection is mhamm. What should you do? ()A、 Change the connection string as follows:Data Source=DB01;Initial Catalog=Trades;UID=mhamm; PWD=password;"B、 Create a login for Mia Hamm on DB01.C、 Create a database user object in Trades and map the object to the SQL Server 2005 Login of Mia Hamm.D、 Change the connection string as follows:"Server=DB01;Database=Trades;UID=mhamm;PWD=password;"
考题
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application. The database on the Microsoft SQL Server 2005 database has two tables that are displayed by using two SqlConnection objects in two different GridView controls. You want the tables to be displayed at the same time with the use a single SqlConnection object. What should you do?()A、 Create a bound connection by using the sp_getbindtoken and the sp_bindsession stored procedures.B、 Enable Multiple Active Result Sets (MARS) in the connection string of the application. C、 Create an exception handler for the connection-busy exception that is thrown on using a single SqlConnection object.D、 Run the two SqlDataReader objects by using a single SqlCommand object.
考题
单选题You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You want to use Windows Authentication along with the Microsoft OLE DB provider. You now need to make sure that the OLE DB connection is as secure as possible. What should you do?()A
Add the following parameter to the connection string: Integrated Security=true; PersistSecurityInfo=true;B
Add the following parameter to the connection string: Integrated Security=SSPI;C
Add the following parameter to the connection string: Integrated Security=SSPI; PersistSecurityInfo=yes;D
Add the following parameter to the connection string: Integrated Security=true;
考题
多选题ou create a page in an ASP.NET Web application. The page retrieves and displays data from a Microsoft SQL Server database. You need to create a data source that can connect to the database. What are two possible ways to achieve this goal?()AUse an ObjectDataSource control and set its TypeName property to System.Data.SqlClient.SqlConnection.BUse a SqlDataSource control and configure its ConnectionString in the web.config file.CUse an XmlDataSource control together with an Xml control that represents the database.DUse a LinqDataSource control with entity classes that represent the elements in the database.
考题
填空题"在连接数据库的过程中,数据库连接字符串为: Data Source=localhost; Initial Catalog= Haier; user id=sa; password=123456; Data Source代表什么含义:() Initial Catalog代表什么含义:() user id代表什么含义:() password代表什么含义:()"
考题
多选题以下关于连接字符串的描述中,正确的是()和()。AData Source属性表示数据库的类型BTrusted_Connection参数决定连接是否使用信任连接CIntegrated Security参数决定连接是否使用信任连接DInitial Catalog表示数据库的类型
考题
单选题你使用VisualStudio.NET开发了一个基于Windows的应用程序App。App使用对象SqlConnection来进行数据库访问。你在一台内存和硬盘空间均受限制的计算机上运行App。当代码完成对SqlConnection对象的使用后,你必须保证连接被关闭,且任何被该对象使用的资源必须立即释放。你该做什么?()A
调用SqlConnection对象的Finalize方法B
调用SqlConnection对象的Dispose方法C
设置SqlConnection对象为NothingD
设置SqlConnection对象为“”
考题
单选题You design a Business Intelligence (BI) solution by using SQL Server 2008. You create a SQL Server 2008 Reporting Services (SSRS) solution by using SQL Server 2008. Several reports on the server use a shared data source named DSProduction. You modify an existing report that uses the DSProduction data source. After deployment, the modified report must use an alternate data source. You need to prevent the modified report from affecting other reports. What should you do?()A
Update the connection string of the DSProduction shared data source to point to the alternate data source.B
Update the modified report to use a report-specific data source. Update the connection string of the report-specific data source to point to the alternate data source.C
Create a new shared data source named DSProduction in the same folder as that of the modified report. Update the connection string of the new shared data source to point to the alternate data source.D
Disable the DSProduction data source. Update the modified report to use a report-specific data source. Update the connection string of the report-specific data source to point to the alternate data source.
热门标签
最新试卷