vb.net - Obtaining Databases from SQL Server 2008 using vb in VS 2012 -
i new asp.net have knowledge vb. building web application in visual studio 2012 using vb. have drop down list populated 2 2008 sql servers. there dropdown need populated list of available databases on selected server. have button once clicked , server selected query , pull list of databases
i have specified server name in globalvariables class , imported form using.
i thinking need if statement need say, if server1 selected open connection , perform query on databases.
here code have throwing overload resolution failed because no accesible 'open' accepts number of arguments error:
protected sub getdb_click(sender object, e eventargs) handles getdb.click dim objconnection oledbconnection objconnection = createobject("oledbconnection") if dropdownlist1.text = globalvariables.servername1 objconnection.open("provider=sqloledb; data source=" & "globalvariables.servername1" & ";" & _ "trusted_connection=yes; initial catalog=master") end if
please me in getting correct code have tried number of items off of site , nothing seems work.
you use new keyword instantiate objects
dim servername = dropdownlist1.text dim connectionstring = "provider=sqloledb; data source=" & servername & ";" & _ "trusted_connection=yes; initial catalog=master" dim objconnection = new oledbconnection(connectionstring) objconnection.open()
and pass instructions on how open database using connectionstring.
however, because using sqlserver database why don't use specific classes provided sql server?
sqlconnection, sqlcommand, sqldataadapter , on....
Comments
Post a Comment