ExecuteReader: Connection property has not been initialized

前端 未结 7 1453
广开言路
广开言路 2021-01-01 08:29

ExecuteReader: Connection property has not been initialized.

my coding is

protected void Button2_Click(object sender,          


        
7条回答
  •  天命终不由人
    2021-01-01 09:22

    All of the answers is true.This is another way. And I like this One

    SqlCommand cmd = conn.CreateCommand()
    

    you must notice that strings concat have a sql injection problem. Use the Parameters http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx

提交回复
热议问题