Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
Alter Table MySQL
lunedì 24 marzo 2014 - 21.51
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
VB.NET
|
.NET 4.0
|
MySQL 5.5
Mau67
Profilo
| Expert
917
messaggi | Data Invio:
lun 24 mar 2014 - 21:51
Buona sera al forum
come anticipato nel titolo ho creato un programma che aggiunge i database e le tabelle in mysql, fino alla creazione dei database e delle tabelle nessun problema il mio problema è nel alter table cioè dopo aver creato le tabelle se devo aggiungere campi o modificarli non so come comportarmi sapreste darmi una mano? vi posto il codice che uso per aggiungere le tabelle da un datagridview
[code/]Private Sub btnCreateTbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateTbl.Click
' Dim field As New List(Of String)
Dim field As String
Dim type As String
Dim nlenght As Integer
Dim nNull As String
Dim nIndex As String
Dim nAI As String
Dim alltxt As String
Dim tblAndDB As String = lblDbname.Text & "." & txttblName.Text
Dim TBLCREATE As String = "CREATE TABLE " & tblAndDB & " ( "
For i As Integer = 0 To Me.dtgStructNewTbl.Rows.Count - 2
' field.Add(Me.dtgStructNewTbl.Rows(i).Cells("n_field").Value)
field = Me.dtgStructNewTbl.Rows(i).Cells("n_field").Value
type = Me.dtgStructNewTbl.Rows(i).Cells("n_type").Value
nlenght = Me.dtgStructNewTbl.Rows(i).Cells("n_lenght").Value
nNull = Me.dtgStructNewTbl.Rows(i).Cells("n_null").Value
nIndex = Me.dtgStructNewTbl.Rows(i).Cells("n_index").Value
nAI = Me.dtgStructNewTbl.Rows(i).Cells("n_ai").Value
alltxt += field & " " & type & "(" & nlenght & ")" & " " & nNull & " " & nIndex & " " & nAI & "," & vbNewLine
Next
Try
'it removes all the newline and whitespaces
alltxt = alltxt.Substring(0, alltxt.Length - Environment.NewLine.Length)
Dim cleanText As String
'it removes the the last comma ","
cleanText = alltxt.Remove(alltxt.Length - 1)
Dim finalText As String
'combination of finalText with table name and Mysql ENGINE
finalText = TBLCREATE & cleanText & ")ENGINE = MYISAM ;"
jokenCreateTable(finalText)
Button1_Click(sender, e)
Catch ex As Exception
txtcomement.ForeColor = Color.Red
txtcomement.Text = ex.Message
End Try
End Sub[\code]
grazie
Mau67
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !