| 发表于:2008-02-19 15:07:41 楼主 |
我用odbcconnection连接的数据库怎样进行插入操作啊,我写的下面的代码,不能成功插入,单独运行sql语句没有问题的,而却数据库也能连接成功的,那位高手帮帮忙啊 public sub btclick(byval str as string) select case str case "btn_add" dim gcompy_cd as string dim gcompy_mei as string dim gcompy_info as string dim gbusuu as integer dim sql as string dim addtime as string dim str1 as string = "dsn=datasoure;uid=yuyanping-pc;pwd=;" dim cnn as odbcconnection = new odbcconnection(str1) dim cmd as odbcdataadapter 'dim dt as datatable gcompy_cd = me.comb_cmpcd.text gcompy_mei = me.txt_cmpmei.text gcompy_info = me.txt_cmpinfo.text gbusuu = me.txt_busuu.text addtime = format(now(), "yyyy/mm/dd hh:mm:ss") cnn.open() sql = "insert into compy_mst(compy_cd,compy_mei,compy_info,busuu,makeymd,updymd)values('" & gcompy_cd & "','" & gcompy_mei & "','" & gcompy_info & "'," & gbusuu & ",'" & addtime & "',null)" 'cmd = new odbcdataadapter(sql, cn) dim mycommand as sqlcommand = new sqlcommand(sql, cnn) 'sqlcommand(mycommand = new sqlcommand(sql, cn)) cn.close() end select end sub |
|
|
|
|