第1个回答 2009-12-02
你把TXT内容和数据库字段粘一下 我觉得可以帮你写
不过你也可以再试试
你看看 我的思路行不 首先 读入TXT文件 然后用readline一行一行的用split方法+substring方法解析你的TXT的内容,
然后再用insert into table values 的sql语句 把解析的值插入数据库
关键点在于你的TXT文件什么格式,就是解析那步比较难 我先贴个 我随便模拟写的 类JAVA properties类的解析
static Hashtable hst;
//读取properties文件
public static void load(string filePath)
{
hst = new Hashtable();
string line = null;
string key = null;
string value = null;
string[] temp = null;
//int i = 0;
StreamReader sr = new StreamReader(filePath);
while (sr.Peek() >= 0)
{
line = sr.ReadLine();
if (!line.StartsWith("#"))
{
temp = line.Split('=');
key = temp[0];
value = temp[1];
hst.Add(key, value);
}
}
sr.Close();
}
这里是解析 文件
希望能帮到你
第2个回答 2009-12-02
先把文件名改成。cpp格式
再打开C语言的界面,
在File栏Open选项里面找到刚才的那个文件打开就可以了
第3个回答 2009-12-02
首先将文件的内容读出来,放在内存里。语句是
insert into 表名 列名 values(.....)
INSERT INTO php_table( `id`, `username`, `others` ) VALUES( '$id', '$username', '$others' )