Built table using ODBC

dukati

New member
Joined
Aug 10, 2009
Messages
3
Programming Experience
1-3
Hello all..i'm want to know why my program not work.I want built new table in PostgreSQL using VB.NET but this code not work.My objective while only click one button the new table existed in my PostgreSQL.Please tell me what wrong at my program and how to improve it?


Imports System
Imports System.Data
Imports System.Data.Odbc



Public Class Form1

Dim thisConnection As New OdbcConnection _
("dsn=MyOdbc")
Dim nonqueryCommand As OdbcCommand = thisConnection.CreateCommand()

Public sConnection As String = "DSN=PostgreSQL30;UID=tele;PWD=tiny;"
Public cnDB As New Odbc.OdbcConnection(sConnection)

Public dsDB As New DataSet
Public adDB As New Odbc.OdbcDataAdapter


Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
nonqueryCommand.CommandText = "CREATE TABLE mytable " & _
"(MyName VARCHAR (30), MyNumber INTEGER)"
'Console.WriteLine("Executing {0}", _
' nonqueryCommand.CommandText)
'Console.WriteLine("Number of rows affected : {0}", _
' nonqueryCommand.ExecuteNonQuery())
Try
cnDB.Open()
'adDB.SelectCommand = New Odbc.OdbcCommand(" CREATE TABLE sensor_result_test ")

MsgBox("Connect to Database", MsgBoxStyle.Information, "Success")
cnDB.Close()
Catch ex As Exception
MsgBox("Connection to database Failed", MsgBoxStyle.Critical, "Action Failed")
End Try


End Sub

End Class


My file is included in here.

RapidShare: 1-CLICK Web hosting - Easy Filehosting

TQ very much.
 
You've commented out the line that executes the SQL code. If you don;t execute the SQL then what it's supposed to do is not going to happen. It's all very well getting yourself a dog but if you don't tell it to fetch then your stick is going to stay where it is.
 
Back
Top