sql - vb error: Value of type 'String' cannot be converted to 'System.Data.SqlClient.SqlCommand' -
i'm novice vb programmer , i'm sure solution trivial, however, getting above error when try display results of 1 of stored procs in sql server doesn't need parameters. how can fix this?
my code excerpt:
dim sqlcmd sqlcommand = new sqlcommand() sqlcmd.commandtext = "exec alltablecount" sqlcmd.commandtype = commandtype.storedprocedure sqlcmd.connection = globalfunctions.globalf.getdevsqlserverstoredprocedure(sqlcmd.commandtype) sqlcmd.executenonquery() msgbox(sqlcmd.executenonquery) where getdevsqlserverstoredprocedure defined in different file as:
public shared function getdevsqlserverstoredprocedure(byval sql string) dim dbconn sqlconnection dim dbcommand sqldataadapter dim dspagedata new system.data.dataset dbconn = new sqlconnection(configurationsettings.appsettings("amdmetricsdevconnectionstring")) dbcommand = new sqldataadapter(sql) 'this line errors on' dbcommand.fill(dspagedata, "exceptions") return dspagedata end function i can see sp vs 2008 in server explorer. problem seems don't know how connect data adapter sp. string query.
command text should name of stored procedure tim mentioned.
it looks problem having passinging commandtype method getdevsqlserverstoredprocedure instead of string.
Comments
Post a Comment