简体   繁体   中英

Why use Visual Studio 2013 + Microsoft SQL Server 2017 Developer to connect Database have blank page

I use Visual Studio 2013 + Microsoft SQL Server 2017 Developer to connect Database have blank page.

I use guide at SQL Server 2017 Developer edition user cannot connect cannot to solve problem , I have to true solve answer to connect Database not to blank page.

Image to describe in present.

  1. I have settings to mix authentication mode.

  2. I have settings to open sa user completely.

  3. I use localhost:8081 and open Welcome Screen normally.

  4. I set password of user sa to blank.

  5. I try compile to code in example and have blank page (no table process).

My Code.

SQL

USE [mydatabase]
GO
/****** Object:  Table [dbo].[customer]    Script Date: 05/01/2012 16:44:29             ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[customer](
[CustomerID] [varchar](4) NOT NULL,
[Name] [varchar](50) NULL,
[Email] [varchar](50) NULL,
[CountryCode] [varchar](2) NULL,
[Budget] [float] NULL,
[Used] [float] NULL,
CONSTRAINT [PK_customer] PRIMARY KEY CLUSTERED 
(
[CustomerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

INSERT INTO customer VALUES ('C001', 'Win Weerachai', 'win.weerachai@a.com', 'TH', 1000000, 600000);
INSERT INTO customer VALUES ('C002', 'John  Smith', 'john.smith@a.com', 'EN', 2000000, 800000);
INSERT INTO customer VALUES ('C003', 'Jame Born', 'jame.born@a.com', 'US', 3000000, 600000);
INSERT INTO customer VALUES ('C004', 'Chalee Angel', 'chalee.angel@a.com', 'US', 4000000, 100000);

ASP.Net C#

<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Page Language="C#" Debug="true" %>
<script runat="server">

SqlConnection objConn;
SqlCommand objCmd;

void Page_Load(object sender,EventArgs e)
{
    String strConnString;
    strConnString = "Server=localhost:8081;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;";
    objConn = new SqlConnection(strConnString);
    objConn.Open();

    BindData();
}

void BindData()
{
    String strSQL;
    strSQL = "SELECT * FROM customer";

    SqlDataReader dtReader;
    objCmd = new SqlCommand(strSQL, objConn);
    dtReader = objCmd.ExecuteReader();

    //*** BindData to Repeater ***//
    myRepeater.DataSource = dtReader;
    myRepeater.DataBind();

    dtReader.Close();
    dtReader = null;

}

void Page_UnLoad()
{
    objConn.Close();
    objConn = null;
}

</script>
<html>
<head>
<title>a.com ASP.NET - SQL Server 2012</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate>
    <table border="1">
        <tr>
            <th>CustomerID</th>
            <th>Name</th>
            <th>Email</th>
            <th>CountryCode</th>
            <th>Budget</th>
            <th>Used</th>
        </tr>
</HeaderTemplate>
<ItemTemplate>
    <tr>
        <td align="center"><asp:Label id="lblCustomerID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustomerID") %>'></asp:Label></td>
        <td><asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label></td>
        <td><asp:Label id="lblEmail" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Email") %>'></asp:Label></td>
        <td align="center"><asp:Label id="lblCountryCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CountryCode") %>'></asp:Label></td>
        <td align="right"><asp:Label id="lblBudget" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Budget") %>'></asp:Label></td>
        <td align="right"><asp:Label id="lblUsed" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Used") %>'></asp:Label></td>
    </tr>           
</ItemTemplate>
<AlternatingItemTemplate>
    <tr bgcolor="#e8e8e8">
        <td align="center"><asp:Label id="lblCustomerID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustomerID") %>'></asp:Label></td>
        <td><asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label></td>
        <td><asp:Label id="lblEmail" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Email") %>'></asp:Label></td>
        <td align="center"><asp:Label id="lblCountryCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CountryCode") %>'></asp:Label></td>
        <td align="right"><asp:Label id="lblBudget" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Budget") %>'></asp:Label></td>
        <td align="right"><asp:Label id="lblUsed" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Used") %>'></asp:Label></td>
    </tr>           
</AlternatingItemTemplate>
</asp:Repeater>
</form>
</body>
</html>

Thanks you very much to suggestion.

I found answer to solve problem = During saving code file , set charset UTF-8 to fix problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM