Build new table using VB.NET in PostgreSQL

Build new table using VB.NET in PostgreSQL

am 18.08.2009 16:25:30 von Mohd Rizal Md Noor

--001636b2ad2169972704716b4a79
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hello all..i'm want to know why my program not work.I want built new table
in PostgreSQL using VB.NET but that code not work.only click one button 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

why new table not existed in my postgresql?please help me.tq.

--001636b2ad2169972704716b4a79
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello all..i'm want to know why my program not work.I want built n=
ew table in PostgreSQL using but that =
code not work.only click one button new table existed in my PostgreSQL.Plea=
se tell me what wrong at my program and how to improve it?



Imports System
Imports System.D=
ata
Imports System.Data.Odbc



Public Class Form1

=
=A0 Dim thisConnection As New OdbcConnection _
=A0 ("dsn=3D=
MyOdbc")

=A0 Dim nonqueryCommand As OdbcCommand =3D thisConnection.CreateCommand()=

=A0 =A0
=A0 Public sConnection As String =3D "DSN=3DPostgreS=
QL30;UID=3Dtele;PWD=3Dtiny;"
=A0 Public cnDB As New Odbc.OdbcConn=
ection(sConnection)


=A0 Public dsDB As New DataSet
=A0 Public adDB As New Odbc.OdbcD=
ataAdapter


=A0 Private Sub Button1_Click(ByVal sender As Syste=
m.Object, _
=A0 ByVal e As System.EventArg=
s) _

=A0 Handles Button1.Click
=A0 =
nonqueryCommand.CommandText =3D "CREATE TABLE mytable " & _ r>=A0 "(MyName VARCHAR (30), MyNumber INTEGER)"
=
=A0 'Console.WriteLine("Executing {0}", _

=A0 ' nonqueryCommand.CommandText)
=A0 'Console.Wr=
iteLine("Number of rows affected : {0}", _
=A0 ' n=
onqueryCommand.ExecuteNonQuery())
=A0 Try
=A0 cnDB.Op=
en()

=A0 'adDB.SelectCommand =3D New Odbc.OdbcCommand(" CREAT=
E TABLE sensor_result_test ")

=A0 MsgBox("Connec=
t to Database", MsgBoxStyle.Information, "Success")
=A0 =
cnDB.Close()

=A0 Catch ex As Exception
=A0 MsgBox("Connection to=
database Failed", MsgBoxStyle.Critical, "Action Failed") >=A0 End Try


=A0 End Sub

End Class

<=
div>
why new table not existed in my postgresql=
?please help me.tq.


--001636b2ad2169972704716b4a79--