Definiste la funcion "GenerarColumnas" como static? (algo asi como "internal static void GenerarColumnas(....")
2011/9/19 Pepe Ballaga <[email protected]> > ** > Holaaa tengo que mandar a ejecutar un programa cada cierto tiempo y opte > por hacer en c# una aplicacion tipo consola, para despues convertirla en un > servicio a ejecutar por el servidor ¿eso esta bien pensado?. tambien tengo > un problema pues algo tan comun como hacer una funcion me da error. a > continuacion pongo el codigo de ejemplo: > > > foreach (string name in alldatabases) > > { > > SqlConnection conexion2 = new SqlConnection("Data source =" + Properties. > Settings.Default["winccserver"].ToString() + "; Initial Catalog = " + name > + "; Persist Security Info=True; user id=" + Properties.Settings.Default[ > "winccuser"].ToString() + "; password=" + Properties.Settings.Default[ > "winccpassword"].ToString() + ";"); > > SqlCommand comando2 = new SqlCommand("SELECT * from > INFORMATION_SCHEMA.TABLES where TABLE_NAME='PDE#TAGs'", conexion2); > > conexion2.Open(); > > SqlDataReader datareader2 = comando2.ExecuteReader(); > > if (datareader2.HasRows) > > { > > //tagInfos ti = new tagInfos("Provider=SQLOLEDB; Data Source =" + > ConfigurationManager.AppSettings["winccserver"].ToString() + "; uid=" + > ConfigurationManager.AppSettings["winccuser"].ToString() + "; pwd=" + > ConfigurationManager.AppSettings["winccpassword"].ToString() + "; Initial > Catalog = " + ConfigurationManager.AppSettings["winccdatabase"].ToString() + > ";"); > > tagInfos ti = new tagInfos("Provider=SQLOLEDB; Data Source =" + > Properties.Settings.Default["winccserver"].ToString() + "; uid=" + > Properties.Settings.Default["winccuser"].ToString() + "; pwd=" + > Properties.Settings.Default["winccpassword"].ToString() + "; Initial > Catalog = " + name + ";"); > > //generar columnas lo que hace es que si existe una variable nueva pues > agrega la columna a temporal > > DataTable tabla = ti.getTaginfos(); > > GenerarColumnas(tabla); > > break; > > } > > } > > > > el problema esta en llamar a la funcion. me da un error rarisimo me dice:" > Error 3 Se requiere una referencia de objeto para el campo, método o > propiedad no estáticos 'Connectivity.Program.GenerarColumnas > System.Data.DataTable)' D:\GEDICH\Consola\Connectivity\Program.cs 92 21 > Connectivity > " > > > > Muchas gracias > > > > PEPE >
