Hola wenas de nuevo
explico lo que quiero es cargar datos de mi base de datos a mi datagridview
el codigo q uso es este
Código:
query = "SELECT * FROM articulos where codigo='" & cbbuscar.Text & "'"
cmd.Connection = conec
cmd.CommandText = "SELECT * FROM articulos where codigo='" & cbbuscar.Text & "'"
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
dt = New DataTable
da = New Odbc.OdbcDataAdapter(cmd)
da.Fill(dt)
dgv.DataSource = dt
With (dgv)
.MultiSelect = False
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.DataSource = dgv.DataSource
End With
pero la cmd.connection = conec me dice q conec
"un valor de tipo "conexion" no puede convertirse en "system.data.odbc.odbcconnection""
mi clase conexion es
Código:
Public Class conexion
Public Reader As Odbc.OdbcDataReader
Public conec As New Data.Odbc.OdbcConnection
Public comando As New Odbc.OdbcCommand
Public conec2 As New Odbc.OdbcConnection
Dim uid, pwd As String
Sub New()
End Sub
Sub New(ByVal usuario As String, ByVal pass As String)
conectar(usuario, pass)
End Sub
Sub conectar(ByVal uid As String, ByVal pwd As String)
Try
If conec.State = ConnectionState.Closed Then
conec.ConnectionString = "DSN=sqlvc;Uid=" & uid & ";pwd=" & pwd & ";"
conec.Open()
End If
Catch ex As Exception
MsgBox("Usuario no válido")
End Try
End Sub
y tengo en mi modulo valglobal
Código:
Module ValGlobal
Public query As String
Public query2 As String
Public conec As New conexion("root", "")
Public ds As DataSet
Public dt As DataTable
Public dr As Odbc.OdbcDataReader
Public da As Odbc.OdbcDataAdapter
Public cmd As Odbc.OdbcCommand
End Module
con mis datos apra conectar
entonses cual es el problema ??
desde ya muchas gracias
Saludos