Salvataggio Di Un Datagrid Su Una Tabella

maxAspra

Nuovo Utente
1
0
Salve,
ho un problemino con il mio visual studio.
ho caricato un file di tipo testo tramite codice con la seguente sintassi:
e tutto funziona regolarmente.

With OpenFileDialog1
.CheckFileExists =
True
.CheckPathExists = True
.DefaultExt = "txt"
.DereferenceLinks = True
.ValidateNames = True
.Filter = "Text files (*.txt)|*.txt|All files|*.*"
.RestoreDirectory = True
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim filename AsString
filename = .FileName
Dim ts = New IO.StreamReader(.OpenFile)
Me.TextBox1.Text = OpenFileDialog1.FileName
EndIf
EndWith
Dim objStreamreader As IO.StreamReader = _
New IO.StreamReader(Me.TextBox1.Text)
Dim strline AsString
Dim strcolomns() AsString
'Dim dtCustomers As New DataTable()
Dim drCustomer As DataRow
dtCustomers.Columns.Add(
"Cognome")
dtCustomers.Columns.Add(
"Nome")
dtCustomers.Columns.Add(
"CodiceCliente")
dtCustomers.Columns.Add(
"telefono")
dtCustomers.Columns.Add(
"cellulare")
strline = objStreamreader.ReadLine
DoWhile (Not strline IsNothing)
drCustomer = dtCustomers.NewRow
strcolomns = Split(strline,
",")
drCustomer.ItemArray = strcolomns
dtCustomers.Rows.Add(drCustomer)
strline = objStreamreader.ReadLine
Loop
datiImportati.DataSource = dtCustomers

adesso dovrei caricare il tutto in una tabella clienti
quindi ho creato un tableadapter è ho creato il comando update
però quando creo un pulsante per richiamarmi la funzione create()
mi sottolinea la funzione create() e mi compare il messaggio
"argomento non specificato per il parametro "select command" di
Public
Function Create(ByVal selectCommand AsString) As System.Data.OleDb.OleDbDataAdapter":D
POTETE AIUTARMI?????


PublicFunction Create(ByVal selectCommand AsString) As System.Data.OleDb.OleDbDataAdapter

Dim strConn AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
strConn = strConn & "C:\pratiche\database.mdb"
Using connection AsNew System.Data.OleDb.OleDbConnection(strConn)
connection.Open()
Dim adapter As OleDb.OleDbDataAdapter = _
New OleDb.OleDbDataAdapter(selectCommand, connection)
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
' Create the commands.
adapter.InsertCommand = New OleDb.OleDbCommand( _
"INSERT INTO Clienti (Cognome, nome,codicecliente,cellulare,telefono) " & _
"VALUES (?, ?)")
adapter.UpdateCommand =
New OleDb.OleDbCommand( _
"UPDATE Clienti SET Cognome = ?, nome = ?,cellulare = ?, telefono = ?" & _
"WHERE id_cliente = ?")
adapter.DeleteCommand =
New OleDb.OleDbCommand( _
"DELETE FROM Clienti WHERE id_cliente = ?")
' Create the parameters.
adapter.InsertCommand.Parameters.Add( _
"@id_cliente", OleDb.OleDbType.Char, 5, "id_cliente")
adapter.InsertCommand.Parameters.Add( _
"@cognome", OleDb.OleDbType.VarChar, 50, "cognome")
adapter.InsertCommand.Parameters.Add( _
"@nome", OleDb.OleDbType.VarChar, 50, "nome")
adapter.InsertCommand.Parameters.Add( _
"@cellulare", OleDb.OleDbType.VarChar, 50, "cellulare")
adapter.InsertCommand.Parameters.Add( _
"@telefono", OleDb.OleDbType.VarChar, 50, "telefono")
adapter.UpdateCommand.Parameters.Add( _
"@id_cliente", OleDb.OleDbType.Char, 5, "id_cliente")
adapter.UpdateCommand.Parameters.Add( _
"@cognome", OleDb.OleDbType.VarChar, 50, "cognome")
adapter.UpdateCommand.Parameters.Add( _
"@nome", OleDb.OleDbType.VarChar, 50, "nome")
adapter.UpdateCommand.Parameters.Add( _
"@cellulare", OleDb.OleDbType.VarChar, 50, "cellulare")
adapter.UpdateCommand.Parameters.Add( _
"@telefono", OleDb.OleDbType.VarChar, 50, "telefono")
adapter.UpdateCommand.Parameters.Add( _
"@oldid_cliente", OleDb.OleDbType.Char, 5, "id_cliente").SourceVersion = _
DataRowVersion.Original
adapter.DeleteCommand.Parameters.Add( _
"@id_cliente", OleDb.OleDbType.Char, 5, "id_cliente").SourceVersion = _
DataRowVersion.Original
Return adapter
connection.Close()
EndUsing
ds.Tables.Add(dtCustomers)
Create.Update(ds,
"clienti")
EndFunction
 

Entra

oppure Accedi utilizzando

Discussioni Simili