X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 058FE9DCB68 for ; Wed, 8 Mar 2006 16:19:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64595-07 for ; Wed, 8 Mar 2006 16:19:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from gk-us2.us.michelin.com (gk-us2.michelin.com [156.65.14.19]) by postgresql.org (Postfix) with ESMTP id 0D6E39DCB11 for ; Wed, 8 Mar 2006 16:19:43 -0400 (AST) Received: from oncpfxp3-out.onc.michelin.com (unverified [10.21.4.30]) by gk-us2.us.michelin.com (Clearswift SMTPRS 5.1.7) with ESMTP id for ; Wed, 8 Mar 2006 15:19:10 -0500 Received: from ONCMH1.onc.michelin.com (ONCMH1.onc.michelin.com [156.65.124.40]) by oncpfxp3-out.onc.michelin.com (Postfix) with ESMTP id 2DD17206B0 for ; Wed, 8 Mar 2006 15:19:44 -0500 (EST) Received: from oncmtap1.onc.michelin.com by oncmh1.onc.michelin.com with ESMTP for pgsql-odbc@postgresql.org; Wed, 8 Mar 2006 15:19:43 -0500 Received: from oncems01.onc.michelin.com ([156.65.125.150]) by oncmtap1.onc.michelin.com (Netscape Messaging Server 4.15) with ESMTP id IVTSGP00.36T for ; Wed, 8 Mar 2006 15:19:37 -0500 Received: from [10.43.12.183] (unverified) by oncems01.onc.michelin.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Wed, 8 Mar 2006 15:19:37 -0500 Message-Id: <440F3C55.8090400@us.michelin.com> Date: Wed, 08 Mar 2006 15:19:33 -0500 From: "Campbell, Greg" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: dodol garut , pgsql-odbc@postgresql.org Subject: Re: Need help postgre with visual basic References: <20060308153229.15246.qmail@web37601.mail.mud.yahoo.com> In-Reply-To: <20060308153229.15246.qmail@web37601.mail.mud.yahoo.com> Content-Type: multipart/mixed; boundary="------------050208090308010902040507" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=2.232 required=5 tests=[AWL=0.080, RCVD_IN_WHOIS_INVALID=2.151, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 2.232 X-Spam-Level: ** X-Archive-Number: 200603/45 X-Sequence-Number: 7331 This is a multi-part message in MIME format. --------------050208090308010902040507 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi dodol garut. Your applicaton looks nearly workable. Recommendations: 1. Use care when sending code that contains a connection string with password. 2. Use pgAdmin to build your database creation scripts. 3. Use VB help, particulary MSDN to nail down syntax of ADO commands. 4. Name your global supermarkt ADO Connection object something like gcnnSupermarket intead of dbSupermarket. Almost all connection objects are named "cnn"-something or "conn"-something. The "g" is just an indication or a variable that is global to your applicaiton. 5. Test your connection string in isolation, to see if that works. 6. Rather than applying adUseClient to the connection object apply it to each recordset (e.g. rs.CursorLocation = adUseClient) 7. Do NOT use adDynamic for a cursor type parameter, (unless you REALLY REALLY mean to). 8. Eliminate statements that do nothing (e.g. ExecuteSQL = AffectedRecords). ExecuteSQL was supposed to be an function, but that function is not in your code, and it would be on the other side of the equals sign. 9. Once you get the select and insert to work, explore PostgreSQL functions. They act like stored procedures. Syntax is like "SELECT insert_produk(kodeproduk,namaproduk,hargasatuan)". See PostgreSQL docs on how to build functions (return type void). pgAdmin again makes this pretty easy. pgAdmin is your friend. expected code: Sub cmdSave() on error goto err_sub 'change to a single-ton select to guarantee the return on only one record, as long as the table exists StrSQL1 = "select count(*) as kode_count from produk where kodeproduk='" & Text1.Text & "'" Set rsValid = New ADODB.Recordset rsCursorLocation = adUseClient 'put the client cursor location here, just to be sure 'for a read only 1 record query use adForwardOnly and adLockReadOnly rsValid.Open StrSQL1, utama.gcnnSupermarket, adOpenForwardOnly, adlockReadOnly, adCmdText If (rsValid("kode_count") = 0) Then StrSql2 = "insert into produk(kodeproduk,namaproduk,hargasatuan) values('" & _ Text1.Text & "','" & _Text2.Text & "'," & Text3.Text & ")" 'better yet use a Stored Procedure for faster execution and to move db syntax/logic to database 'StrSql2 = "SELECT insert_produk('" & Text1.Text & "','" & _Text2.Text & "'," & Text3.Text & ")" utama.gnnSupermarket.Execute StrSql2 [, AffectedCount, adCmdText] 'don't really need stuff in brackets . . . Else ... End If set rsValid = Nothing exit Sub err_sub: 'err handling, msg boxes, etc. End sub dodol garut wrote: > I try to build a simple visual basic project with PostgreSQL. Here i attach that project. > That project still have problem and i need someone please to solve that problem. > For query is in supermarket.sql > Thanx before > > best regards, > ERIS RISO > Indonesia > > Send instant messages to your online friends http://uk.messenger.yahoo.com > > > ------------------------------------------------------------------------ > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match --------------050208090308010902040507 Content-Type: text/x-vcard; charset=utf-8; name="greg.campbell.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="greg.campbell.vcf" begin:vcard fn:Greg Campbell n:Campbell;Greg org:Michelin North America - US5 Lexington;ENG-ASE email;internet:greg.campbell@us.michelin.com title:ASE Systems Engineer tel;work:803-951-5561/x75561 x-mozilla-html:FALSE version:2.1 end:vcard --------------050208090308010902040507--