You are creating a Web Form. You write the following code segment to create a SqlCommand object.Dim conn As SqlConnection = New SqlConnection(connString)conn.Open()Dim cmd As SqlCommand = conn.CreateCommand()cmd.CommandText = "select count(*) from Customers"You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal?()A. Dim customerCount As Object = cmd.ExecuteScalar()lblCompanyName.Text = customerCount.ToString()B. Dim customerCount As Integer = cmd.ExecuteNonQuery()lblCompanyName.Text = customerCount.ToString()C. Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr(0).ToString()D. Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr.ToString()

You are creating a Web Form. You write the following code segment to create a SqlCommand object.Dim conn As SqlConnection = New SqlConnection(connString)conn.Open()Dim cmd As SqlCommand = conn.CreateCommand()cmd.CommandText = "select count(*) from Customers"You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal?()

A. Dim customerCount As Object = cmd.ExecuteScalar()lblCompanyName.Text = customerCount.ToString()

B. Dim customerCount As Integer = cmd.ExecuteNonQuery()lblCompanyName.Text = customerCount.ToString()

C. Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr(0).ToString()

D. Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr.ToString()


相关考题:

SqlConnection,SqlCommand,SqlDataAdapter可获取数据供GridView使用。() 此题为判断题(对,错)。

You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray.You also need to ensure that the code segment assigns the number of bytes that are transferred to an integer variable named bytesTransferred.Which code segment should you use?()A.bytesTransferred=stream1.Read(byteArray,0,80);B.C.D.

You use Microsoft .NET Framework 4 to create a Windows Forms client application.You write the following code segment.The application contains a form of type Form1 that contains a FormSettings object named frmSettings1.You need to maintain the user‘s form size preference each time the user executes the application.Which code segment should you use? ()A.B.C.D.

You are creating a DataTable. You use the following code segment to create the DataTable. (Line numbers are included for reference only.)01 DataTable dt = new DataTable(Products”);02 dt.Columns.Add(new DataColumn(Price”, typeof(decimal)));03 dt.Columns.Add(new DataColumn(Quantity”, typeof(Int32)));04 DataColumn dc = new DataColumn(Total”, typeof(decimal));05 dt.Columns.Add(dc);You need to ensure that the Total column is set to the value of the Price column multiplied by the Quantity column when new rows are added or changed. What should you do? ()A. Add the following code segment after line 05. dc.ExtendedProperties[Total] = Price * Quantity”;B. Add the following code segment after line 05. dc.Expression = “Prince * Quantity”;C. Write an event handler for the DataTable‘s TableNewRow event that updates the row‘s Total.D. Write an event handler for the DataTable‘s ColumnChanged event that updates the row‘s Total.

请找出下面这段程序的错误并修正Public Function getDataFromDB(ByVal strID As String, ByRef tblDT As DataTable) As IntegerDim connStr As String = _System.Configuration.ConfigurationSettings.AppSettings("DBConnectionString")Dim conn As SqlConnectionDim ds As New DataSetDim iRet As Integer = 0Dim sqlDA As SqlDataAdapterDim sqlComm As SqlCommandDim sql As StringIf IsNothing(strID) ThenstrID = String.EmptyEnd IfstrID = strID.Trimconn = New SqlConnection(connStr)Tryconn.Open()sql = "SELECT * FROM WWJB01 WHERE ID LIKE '%" strID "%'"sqlComm = New SqlCommand(sql, conn)sqlDA = New SqlDataAdaptersqlDA.SelectCommand = sqlCommsqlDA.Fill(ds)If Not IsNothing(ds) ThenIf ds.Tables.Count 1 Then tblDT = ds.Tables(0).CopyiRet = ds.Tables(0).Rows.CountEnd IfEnd IfCatch ex As ExceptionThrow exFinallyIf Not conn.State = ConnectionState.Closed Thenconn.Close()conn.Dispose()End IfEnd TryReturn iRetEnd Function

You are creating a Web Form. You write the following code segment to create a SqlCommand object. SqlConnection conn = new.SqlConnection(connString); conn.Open( ); SqlCommand cmd = conn.CreateCommand( ); cmd.CommandText = “select cont(*) from Customers”; You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal? ()A、object customerCount = cmd.ExecuteScalar();lblCompanyName.Text = customerCount.ToString();B、int customerCount = cmd.ExecuteNonQuery();lblCompanyName.Text = customerCount.ToString();C、SqlDataReader dr = cmd.ExecuteReader();dr.Read();lblCompanyName.Text = dr[0].ToString();D、SqlDataReader dr = cmd.ExecuteReader();dr.Read();lblCompanyName.Text = dr.ToString();

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create a page that contains the following code fragment:       You write the following code segment in the code-behind file for the page:   void BindData(object sender, EventArgs e) {   lstLanguages.DataSource =  CultureInfo.GetCultures(CultureTypes.AllCultures);   lstLanguages.DataTextField = "EnglishName";  lstLanguages.DataBind();   }   You need to ensure that the lstLanguages ListBox control maintains the selection of the user during postback.  Which line of code should you insert in the constructor of the page?()A、this.Init += new EventHandler(BindData); B、this.PreRender += new EventHandler(BindData); C、lstLanguages.PreRender += new EventHandler(BindData); D、lstLanguages.SelectedIndexChanged += new EventHandler(BindData);

You are creating a Windows Forms Application by using the .NET Framework 3.5.You plan to design a new control that will be used on multiple forms in the app.You need to ensure that the control meets the following requirement  (1)It retrieves data from a MSSQL Server 2008 database instance. (2)It uses WPF classes to display data.  (3)It uses user-customizable actions when the control is first painted on the form.   What should you do?()A、Create a new custom class for the control that is derived from the Control class.B、Create a new custom class for the control that is derived from the UserControl class.C、Create a new custom class for the control that is derived from the ContentControl class.D、Create a new custom class for the control that is derived from the ContentPresenter class.

You are creating a Web Form. You write the following code segment to create a SqlCommand object.Dim conn As SqlConnection = New SqlConnection(connString)conn.Open( )Dim cmd As SqlCommand = conn.CreateCommand( )cmd.CommandText = "select count(*) from Customers"You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal?()A、Dim customerCount As Object = cmd.ExecuteScalar()lblCompanyName.Text = customerCount.ToString()B、Dim customerCount As Integer = cmd.ExecuteNonQuery()lblCompanyName.Text = customerCount.ToString()C、Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr(0).ToString()D、Dim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr.ToString()

You create a Web Form that allows users to create a new account. You add a CreateUserWizard control by using the following code segment. You need to ensure that the wizard automatically sends an e-mail message to users when they finish creating their accounts. You add a valid element to the Web.config file. Which code segment should you add to the Page_Load event? ()A、Wizard1.RequireEmail = TrueB、Wizard1.Email = "user@address.com"C、Wizard1.MailDefinition.From = "registration@mysite.com"D、SmtpMail.SmtpServer = "mail.contoso.com"

You are creating an ASP.NET Web site. The site has a master page named Custom.master. The code-behind file for Custom.master contains the following code segment.Partial Public Class Custom  Inherits System.Web.UI.MasterPagePublic Property Region As String    Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.LoadEnd SubEnd Class You create a new ASP.NET page and specify Custom.master as its master page.You add a Label control named lblRegion to the new page.  You need to display the value of the master pages Region property in lblRegion.What should you do? ()A、Add the following code segment to the Page_Load method of the page code-behind file. Dim custom As Custom = Me.Parent  lblRegion.Text = custom.RegionB、Add the following code segment to the Page_Load method of the page code-behind file. Dim custom As Custom = Me.Master  lblRegion.Text = custom.RegionC、Add the following code segment to the Page_Load method of the Custom.Master.vb code-behind file. Dim lblRegion As Label = Page.FindControl("lblRegion") lblRegion.Text = Me.RegionD、Add the following code segment to the Page_Load method of the Custom.Master.vb code-behind file. Dim lblRegion As Label = Master.FindControl("lblRegion") lblRegion.Text = Me.Region

You develop a Web application that writes data to a file on a server. You restrict access to the file to specific Windows users. The Web application runs as CONTOSO/ASPNET. You deny anonymous access to the application in IIS. You add the following XML segment in the Web.config file.You need to ensure that the application meets the following requirements:It must impersonate the user when it writes data to the file.It must run as CONTOSO/ASPNET when a user does not access the file. Which two actions should you perform? ()A、Use the following XML segment in the Web.config file. identity impersonate="false"/B、Use the following XML segment in the Web.config file. identity impersonate="true"/C、Use the following code segment to access the file. Dim wp As WindowsPrincipal = _CType(HttpContext.Current.User, WindowsPrincipal) Dim wi As WindowsIdentity = WindowsIdentity.GetCurrent() Dim wic As WindowsImpersonationContext = wi.Impersonate()' Access the file herewic.Undo()D、Use the following code segment to access the file. Dim wi As WindowsIdentity = WindowsIdentity.GetCurrent()Dim wic As WindowsImpersonationContext = _WindowsIdentity.Impersonate(wi.Token)' Access the file herewic.Undo()

You are creating a DataTable. You use the following code segment to create the DataTable. (Line numbers are included for reference only.) 01 Dim dt As New DataTable("Products") 02 dt.Columns.Add(New DataColumn("Price", _ GetType(Decimal))) 03 dt.Columns.Add(New DataColumn("Quantity", _ GetType(Int32))) 04 Dim dc As DataColumn = New DataColumn("Total", _ GetType(Decimal)) 05 dt.Columns.Add(dc) You need to ensure that the Total column is set to the value of the Price column multiplied by the Quantity column when new rows are added or changed. What should you do? ()A、Add the following code segment after line 05. dc.ExtendedProperties("Total") = "Price * Quantity"B、Add the following code segment after line 05. dc.Expression = "Price * Quantity"C、Write an event handler for the DataTable's TableNewRow event that updates the row's Total.D、Write an event handler for the DataTable's ColumnChanged event that updates the row's Total.

Your Web site processes book orders. One of the application methods contains the following code segment.Dim doc As New XmlDocument( )doc.LoadXml("10" _"Dictionary")You need to remove the discount element from XmlDocument. Which two code segments can you use to achieve this goal? ()A、Dim root As XmlNode = doc.DocumentElementroot.RemoveChild(root.FirstChild)B、Dim root As XmlNode = doc.DocumentElementroot.RemoveChild(root.SelectSingleNode("discount"))C、doc.RemoveChild(doc.FirstChild)D、doc.DocumentElement.RemoveChild(doc.FirstChild)

You are creating a Windows Forms application by using the .NET Framework 3.5.You plan to develop a new control for the application. You need to ensure that the control extends the DataGridView control by allowing the cells to contain multicolored text. What should you do?()A、Override the OnPaint method.B、Write a code segment to handle the CellPainting event.C、Write a code segment to handle the CellParsing event.D、Write a code segment to handle the RowPostPaint event.

You create a Web Form. The Web Form allows users to recover their passwords. You add a PasswordRecovery server control by using the following code segment.You need to ensure that the server control generates a new password and sends it by e-mail to the users e?mail address. Which two actions should you perform? ()A、Create a valid definition in the Web.config file.B、Set the passwordFormat attribute of the configured membership provider to Encrypted.C、Ensure that the enablePasswordRetrieval attribute of the configured membership provider is set to False.D、Ensure that the enablePasswordRetrieval attribute of the configured membership provider is set to True.

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You want to add an audio player that plays .wav or .mp3 files when the user clicks a button. You plan to store the name of the file to a variable named SoundFilePath. You need to ensure that when a user clicks the button, the file provided by SoundFilePath plays. What should you do?()A、Write the following code segment in the button onclick event. System.Media. SoundPlayer player = new System.Media. SoundPlayer(SoundFilePath); player.play();B、Write the following code segment in the button onclick event. MediaPlayer player = new MediaPlayer(); player.Open(new URI(SoundFilePath), UriKind.Relative)); player.play();C、Use the following code segment from the PlaySound() Win32 API function and call the PlaySound function in the button onclick event. [sysimport(dll="winmm.dll")] public static extern long PlaySound(String SoundFilePath, long hModule, long dwFlags);D、Reference the Microsoft.DirectX Dynamic Link Libraries. Use the following code segment in the button onclick event. Audio song = new Song(SoundFilePath); song.CurrentPosition = song.Duration; song.Play();

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 create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5. You create a Web page that has a GridView control named GridView1. The GridView1 control displays the data from a database named Region and a table named Location. You write the following code segment to populate the GridView1 control:   01 protected void Page_Load(object sender, EventArgs e)   02 {   03   string connstr;   04   05   SqlDependency.Start(connstr);   06   using (SqlConnection connection =   07     new SqlConnection(connstr))   08   {   09     SqlCommand sqlcmd = new SqlCommand();   10     DateTime expires = DateTime.Now.AddMinutes(30);   11     SqlCacheDependency dependency = new   12       SqlCacheDependency("Region", "Location");  13     Response.Cache.SetExpires(expires);   14     Response.Cache.SetValidUntilExpires(true);   15     Response.AddCacheDependency(dependency);   16 ►  17     sqlcmd.Connection = connection;   18     GridView1.DataSource = sqlcmd.ExecuteReader();   19     GridView1.DataBind();   20   }   21 }  You need to ensure that the proxy servers can cache the content of the GridView1 control.  Which code segment should you insert at line 16?()A、Response.Cache.SetCacheability(HttpCacheability.Private); B、Response.Cache.SetCacheability(HttpCacheability.Public); C、Response.Cache.SetCacheability(HttpCacheability.Server); D、Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);

You create a Web Form. The Web Form allows users to log on to a Web site. You implement the login logic using a Login control named Login1. The membership data for the application is stored in a SQL Express database in the App_Data directory. You need to configure your application so that the membership data is stored in a local Microsoft SQL Server database. You add the following code segment to the Web.config file. Which two additional actions should you perform?()A、Use Aspnet_regsql.exe to create the Microsoft SQL Server database.B、Set Login1's MembershipProvider property to MySqlProviderConnection.C、Add the following code segment to the Web.config file.connectionStrings add name="MySqlProviderConnection" connectionString="valid connection string" //connectionStringsD、Add the following code segment to the Web.config file.appSettingsadd key="MySqlProviderConnection" value="valid connection string" //appSettingsE、In the ASP.NET configuration settings within IIS, ensure that Role Management Enabled is selected.F、Use the Web Site Administration Tool to select AspNetSqlMembershipProvider as the membership provider for your application.

You are creating an ASP.NET Web site. You create a HTTP module named Custom Module, and you register the module in the web.config file.The Custom Module class contains the following code. Public Class Custom Module  Implements IHttpModule     Dim footerContent As String = Footer Content"Public Sub Dispose() Implements IHttpModule.DisposeEnd SubEnd Class  You need to add code to CustomModule to append the footer content to each processed ASP.NET page. Which code segment should you use?()A、Public Sub New(ByVal app As HttpApplication) AddHandler app.EndRequest, AddressOf app_EndRequest  End Sub  Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)    Dim app As HttpApplication = TryCast(sender, HttpApplication)  app.Response.Write(footerContent)  End Sub B、Public Sub Init(ByVal app As HttpApplication) _  Implements IHttpModule.Init  AddHandler app.EndRequest, AddressOf app_EndRequest  End Sub Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)  Dim app As HttpApplication = New HttpApplication()  app.Response.Write(footerContent)  End Sub C、Public Sub New()  Dim app As HttpApplication = New HttpApplication()  AddHandler app.EndRequest, AddressOf app_EndRequest End Sub  Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)  Dim app As HttpApplication = TryCast(sender, HttpApplication)  app.Response.Write(footerContent)  End Sub D、Public Sub Init(ByVal app As HttpApplication) _  Implements IHttpModule.Init  AddHandler app.EndRequest, AddressOf app_EndRequest  End Sub  Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)  Dim app As HttpApplication = TryCast(sender, HttpApplication)app.Response.Write(footerContent)  End Sub

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.  You create a Web page that has a GridView control named GridView1. The GridView1 control displays the  data from a database named Region and a table named Location.  You write the following code segment to populate the GridView1 control. (Line numbers are included for reference only.)  01 Protected Sub Page_Load(ByVal sender As Object, _ ByVal e As EventArgs)  02 Dim connstr As String  03 ...  04 SqlDependency.Start(connstr)  05 Using connection As New SqlConnection(connstr)  06 Dim sqlcmd As New SqlCommand()  07 Dim expires As DateTime = DateTime.Now.AddMinutes(30)  08 Dim dependency As SqlCacheDependency = _  09 New SqlCacheDependency("Region", "Location")  10 Response.Cache.SetExpires(expires)  11 Response.Cache.SetValidUntilExpires(True)  12 Response.AddCacheDependency(dependency)  13  14 sqlcmd.Connection = connection  15 GridView1.DataSource = sqlcmd.ExecuteReader()  16 GridView1.DataBind()  17 End Using 18 End Sub  You need to ensure that the proxy servers can cache the content of the GridView1 control. Which code segment should you insert at line 13? () | English | Chinese | Japan | Korean | - 90 - Test Information Co., Ltd. All rights reserved.A、Response.Cache.SetCacheability(HttpCacheability.Private) B、Response.Cache.SetCacheability(HttpCacheability.Public) C、Response.Cache.SetCacheability(HttpCacheability.Server) D、Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate)

多选题You create a Web Form. The Web Form allows users to recover their passwords. You add a PasswordRecovery server control by using the following code segment.You need to ensure that the server control generates a new password and sends it by e-mail to the users e?mail address. Which two actions should you perform?()ACreate a valid definition in the Web.config file.BSet the passwordFormat attribute of the configured membership provider to Encrypted.CEnsure that the enablePasswordRetrieval attribute of the configured membership provider is set to False.DEnsure that the enablePasswordRetrieval attribute of the configured membership provider is set to True.

单选题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 Create an exception handler for the connection-busy exception that is thrown on using a single SqlConnection object.C Run the two SqlDataReader objects by using a single SqlCommand object.D Enable Multiple Active Result Sets (MARS) in the connection string of the application.

多选题You are creating a Web Form. You write the following code segment to create a SqlCommand object.Dim conn As SqlConnection = New SqlConnection(connString)conn.Open( )Dim cmd As SqlCommand = conn.CreateCommand( )cmd.CommandText = "select count(*) from Customers"You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal?()ADim customerCount As Object = cmd.ExecuteScalar()lblCompanyName.Text = customerCount.ToString()BDim customerCount As Integer = cmd.ExecuteNonQuery()lblCompanyName.Text = customerCount.ToString()CDim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr(0).ToString()DDim dr As SqlDataReader = cmd.ExecuteReader()dr.Read()lblCompanyName.Text = dr.ToString()

单选题You are creating a DataTable. You use the following code segment to create the DataTable. (Line numbers are included for reference only.) 01 Dim dt As New DataTable("Products") 02 dt.Columns.Add(New DataColumn("Price", _ GetType(Decimal))) 03 dt.Columns.Add(New DataColumn("Quantity", _ GetType(Int32))) 04 Dim dc As DataColumn = New DataColumn("Total", _ GetType(Decimal)) 05 dt.Columns.Add(dc) You need to ensure that the Total column is set to the value of the Price column multiplied by the Quantity column when new rows are added or changed. What should you do? ()AAdd the following code segment after line 05. dc.ExtendedProperties(Total) = Price * QuantityBAdd the following code segment after line 05. dc.Expression = Price * QuantityCWrite an event handler for the DataTable's TableNewRow event that updates the row's Total.DWrite an event handler for the DataTable's ColumnChanged event that updates the row's Total.

单选题You create a Web Form that allows users to create a new account. You add a CreateUserWizard control by using the following code segment.You need to ensure that the wizard automatically sends an e-mail message to users when they finish creating their accounts. You add a valid element to the Web.config file. Which code segment should you add to the Page_Load event?()AWizard1.RequireEmail = TrueBWizard1.Email = user@address.comCWizard1.MailDefinition.From = registration@mysite.comDSmtpMail.SmtpServer = mail.contoso.com