如果使用VB6.0和后端如果使用本地服务器使用SQL,如何连接前端?

时间:2014-07-03 09:33:47

标签: connection frontend backend

我对编程很新,并且想知道如何使用本地服务器连接前端和后端?

1 个答案:

答案 0 :(得分:0)

1.you need to put a data control in the form then make its visibility to false
2.right click on the page and select view Code
3.in code view write the following code

imports system.data.sqlclient
dim db as database
dim rs as recordset
privete sub form1_load()
set db=opendatabase(app.path & "\db.mdb") // for connect to access database
set rs= db.openrecordset("table_name")// select table in the database
end sub



//** to connect to the sql database
dim cn as sqlconnection
cn=new SQLConnection("connection string")
cmd= new sqlcommand("sql string",cn)
cmd.connection.open
cmd.execute 
cmd.connection.close **//