如何分割字符串. [英] how to split string.
本文介绍了如何分割字符串.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cmd.Parameters.AddWithValue("@Account_No", txtaccount1.Text + "-" + txtaccount2.Text);
在这里,我要在不同文本框中的列中插入数据,如何在不同文本框中从数据库中检索相同数据????
Here I am inserting data in a column from different text boxes, how to retrieve same data from database in different text boxes ????
推荐答案
尝试使用 String.Split方法 [ ^ ].
如果任一文本框中的文本都带有-"字符,则此方法将给您不正确的结果.因此,最好将两个文本框的值存储在数据库的单独列中.
Try using String.Split Method[^].
This method will give you incorrect results if the text in either of the text-boxes have a "-" character. So its better to store the values of both the textbox in separate columns in the database.
拆分字符串
Split String
string str;
str = "Ali-Asadi-...";
string[] master;
master = str.Split((char)45);//45 Key ASCII -
MessageBox.Show(master[0]);
MessageBox.Show(master[1]);
//MessageBox.Show(master[i]);
这篇关于如何分割字符串.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文