[.NET-Winform]细节问题 |
麦林 发表于 2007/7/24 16:25:39 |
1.在此上下文中不允许使用 'a'。此处只允许使用常量、表达式或变量。不允许使用列名问题原因: sql 语句有写错原代码:string a = this.txtTitle.Text.ToString(); string b = this.txtUser.Text.ToString(); string c = this.txtContent.Text.ToString(); string sqlInsert = "insert into talk(userName,title,content) values (a,b,c)"; SqlCommand cmd = new SqlCommand(sqlInsert, conn); cmd.ExecuteNonQuery();正确代码: string a = this.txtTitle.Text.ToString(); string b = this.txtUser.Text.ToString(); string c = this.txtContent.Text.ToString(); string sqlInsert = "insert into talk(userName,title,content) values ('"+a+"','"+b+"','"+c+"')"; SqlCommand cmd = new SqlCommand(sqlInsert, conn); cmd.ExecuteNonQuery();
2.System.Runtime.InteropServices命名空间:是一个有关访问COM对象以及在.NET框架下的本地API函数。在创建COM接口时经常要运用这个命名空间。
3.string转化为byte[]类型方法:string data = "TestData"; byte[] dataArray = System.Text.Encoding.ASCII.GetBytes(data); 4.byte[]类型转化为string方法: byte[] readbuf = new byte[30]; string readbyte = System.Text.Encoding.Default.GetString(readbuf, 4, 10);
5.时间差的计算: datatime a; datatime b; timespan c = b-a;
6.显示窗体的同时隐藏另个窗体:Form1 one = new Form1(); this.Hide(); one.Show();
|
|
|

.: 公告
|
« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
|
.: 我的分类(专题)
|

.: 最新日志
.: 最新回复
|

blog名称:栗色?蓝色? 日志总数:449 评论数量:201 留言数量:37 访问次数:2260608 建立时间:2006年5月16日 |
|

.: 留言板
|

.: 链接
|

|