需要帮助以在webform中显示信息 [英] Need Help to Display Info in webform
本文介绍了需要帮助以在webform中显示信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在web.config文件中有以下代码
i have the following code in web.config file
<connectionstrings>
<add name="ConnectionStringdb" connectionstring="Data Source=local; Initial Catalog=TeltonikaCRM; Persist Security Info=True; User ID=sa;password=Ali998877;">
providerName="System.Data.SqlClient" />
<add name="TeltonikaCRMConnectionString" connectionstring="Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Administrator\Documents\TeltonikaCRM.mdf;Integrated Security=True;Connect Timeout=30">
providerName="System.Data.SqlClient" />
</add></add></connectionstrings>
以及default.aspx.cs中的以下内容
and the following in default.aspx.cs
using System.Data.OleDb;
using System.ComponentModel;
using System.Drawing;
using System.Text;
namespace CRMTracking.Pages
{
public partial class Default2 : System.Web.UI.Page
{
CRMTracking.Classes.DBConnect DBC;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Establishing the MySQL Connection
DBC = new Classes.DBConnect(this.Page);
DBC.SetSqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringdb"].ToString());
DataTable dt = new DataTable();
string query;
SqlCommand SqlCommand;
SqlDataReader reader;
SqlDataAdapter adapter = new SqlDataAdapter();
//Open the connection to db
//Generating the query to fetch the contact details
query = "SELECT * FROM UserInfo";
SqlCommand = new SqlCommand(query, DBC.GetSqlConnection());
//execute the query
reader = SqlCommand.ExecuteReader();
txtFName.Text = reader["UFName"].ToString();
//Assign the results
GridView1.DataSource = reader;
//Bind the data
GridView1.DataBind();
}
}
}
}
和连接类编码是
and a connection Class coding is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI;
namespace CRMTracking.Classes
{
public class DBConnect
{
Page Pg=new Page();
SqlConnection SqlConn;
public DBConnect(Page CurerntPg) {Pg = CurerntPg;}
public void MsgBox(String Message)
{ Pg.ClientScript.RegisterStartupScript(Pg.GetType(), "MessageBox", "<script language='javascript'>alert('" + Message + "');</script>"); }
public SqlConnection GetSqlConnection() {return SqlConn;}
public void SetSqlConnection(String CString)
{
try
{
SqlConn = new SqlConnection(CString);
SqlConn.Open();
}
catch (Exception ce)
{ MsgBox("Error Opening Connection to Sql Server....." + ce); return; }
//
}
}
}
但结果只是一个空白页请帮帮我
but the result is just a blank page please help me
推荐答案
看看第23行,你的不好......
Look at Line 23, there is your bad....
这篇关于需要帮助以在webform中显示信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文