【发布时间】:2010-12-27 13:56:34
【问题描述】:
我正在尝试将 url 从数据库放入 webcontrol。
我创建了 4 个选项卡控件,每个选项卡控件由 webcontrol 组成;我想使用从数据库中获取的网址:
第一个 url 放到 tab1(浏览器在 tab) 第二个 url 放到 tab2 ...
我该怎么做?
private void Form1_Load(object sender, EventArgs e)
{
string MyConString = "SERVER=192.168.0.78;" +
"DATABASE=webboard;" +
"UID=aimja;" +
"PASSWORD=aimjawork;" +
"charset=utf8;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "SELECT url FROM `listweb` WHERE `url` IS NOT NULL AND ( `webbordkind` = 'เว็บท้องถิ่น' ) and `nourl`= 'n' order by province, amphore limit 4 ";
connection.Open();
Reader = command.ExecuteReader();
string thisrow = "";
string sumthisrow = "";
while (Reader.Read())
{
thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString();
// System.IO.File.AppendAllText(@"C:\file.txt", thisrow + " " + Environment.NewLine);
sumthisrow = sumthisrow + thisrow;
}
connection.Close();
}
【问题讨论】:
-
this.webBrowser2.Dock = System.Windows.Forms.DockStyle.Fill; this.webBrowser2.Location = new System.Drawing.Point(3, 3); this.webBrowser2.MinimumSize = new System.Drawing.Size(20, 20); this.webBrowser2.Name = "webBrowser2"; this.webBrowser2.Size = new System.Drawing.Size(410, 420); this.webBrowser2.TabIndex = 0; this.webBrowser2.Url = new System.Uri("msn.com", System.UriKind.Absolute); //
标签: c# database url tabcontrol web-controls