c# 对数据库的操作

来源:互联网 发布:局域网ip扫描软件 编辑:程序博客网 时间:2024/04/29 11:06

     【学习点点滴滴】自己也才学习c#  所以写的都是写简单的。 就是为了记录学习的点点滴滴;

   所以写得比较简。

 

   string id=textbox.text.tostring();

 

   sqlconnection cnn = new sqlconnection( "server=;uid=sa;pwd=1qazwert;database=zaixiantest'');

     sqlcommand cmm= new command();

 

   cmm.connection=cnn; cmm.commandtype=commandtype.text;

   cnn.open();

     cmm.commandtext="select * from yonghu where id='"+id+"'";

     sqldataReader myread = cmm.excutereader();

 

     myreader.Read();

      text1box.text=myreader["yname"].tostring();

     text2.box.text=myreader["ymima"].tostring();

 

原创粉丝点击