师父们,帮我看下我这问题怎么解决呢:
师父们,帮我看下我这问题怎么解决呢:
本人在ASP.NET 2.0的数据库操作练习中写了如下代码,运行就出现了:异常详细信息: System.Data.SqlClient.SqlException: 列名 'myid' 无效。
高手们帮看下问题出在哪了,谢谢!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
protected void Button1_Click(object sender, EventArgs e)
{
connc conncs = new connc();
SqlConnection con = new SqlConnection(conncs.connectionString);
int myid = Convert.ToInt32(TextBox2.Text);
string sql = "SELECT * from texttest2 where id=myid";
SqlCommand cmd = new SqlCommand(sql, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
TextBox3.Text = reader.GetString(1);
else
Label1.Text = "sorry";
reader.Close();
con.Close();
}