Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB5 code to write to a SQL 2000 Table

Status
Not open for further replies.

ITmfgCO

IS-IT--Management
Sep 14, 2006
25
US
I have an urgent issue at my work-place!!!
We are going through an EDI Implementation and need to insert into a Customer Address Table before we can bring the EDI data into the ERP package.
It was suggested to write a VB code to do so. I am not familiar with VB so I need some help.
The VB code has to be able to accept 22 parameters (i.e. Customer_ID, Customer_Name, Address1, Address2, Address3, City, State, .... ect) to push to the Table.
I have tested my Insert statement in SQL Query Analyzer and everything looks fine, but I need the VB code to do this for me. Here is my Insert / Values statement:


INSERT INTO "dbo"."CUST_ADDRESS" ( "CUSTOMER_ID", "NAME", "ADDR_1", "ADDR_2", "ADDR_3", "CITY", "STATE", "ZIPCODE",

"COUNTRY", "DEF_SLS_TAX_GRP_ID", "TAX_EXEMPT", "SHIPTO_ID", "ORDER_FILL_RATE", "GENERATE_ASN",

"HOLD_TRANSFER_ASN", "CUSTOMS_DOC_PRINT", "ACCEPT_830", "ACCEPT_862", "CONSOL_SHIP_LINE",

"PALLET_DETAILS_REQ", "GENERATE_WSA", "HOLD_TRANSFER_WSA" ) VALUES ( 'A200500', 'LTest', 'LAddress Test1',

'LAddress Test2', 'LAddress Test3', 'Carrollton', 'TX', '75006','USA' , NULL, 'N', '2118624474', 0.000000, 'D', 'D', 'D', 'D', 'D', 'N', 'N', 'D', 'D')

RESULT: 0



Any help on this would make my day, it is an extremely urgent issue.
I have no Idea on how to accept these 22 parameters that will be pushed
over to the desired VB code, nor do I know if anything else is required
before I use the Insert / Values statement.

Thanks in advance,
 
George,
Thank you for suggesting to NOT use the sa to log into the DB...yeah that could be an extremely bad thing... thanks for that scare....

Also that link to connection strings is an amazing site....very helpful...


I do have another question...
what is the best way to declare these parameters?
Code:
Dim @custid as String
Dim @name as String
Dim @shipto as Integer


Thanks,
 
The @ symbol is used for in SQL Server for variables (and parameters). Just leave the @ symbol out of the VB code.

>> thanks for that scare....

[smile] You're welcome. Of course, if you create a sql login that has sysadmin rights, it's just as bad. If you choose to use SQL Authentication, then you should create a new login and give it rights to the database you are using. If this is an application that will ONLY be used within your company (i.e. not sold and/or used outside the company), then you may want to consider making this new login be a db_owner for the database. Permissions is a big issue, and one that you need to consider carefully. This is especially true in large companies and/or commercial applications that you distribute.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I would also suggest to use some type of indication of the type of variable you use:
Code:
Dim [blue]str[/blue]custid as String
Dim [blue]str[/blue]name as String
Dim [blue]int[/blue]shipto as Integer
so later in the code you will avoid doing something like:
Code:
shipto = "Iraq"

Have fun.

---- Andy
 
Off this subject but in the same project scope:

Wrapping this program in a Com object????

Can anyone help?

and if so how is it called????

Thanks,
 
Start by re-reading faq222-2244 which will show you how these forums work.

Then start this new question in a new thread. Better still, ask in the right forum - that will be forum796

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
>Off this subject but in the same project scope:

Since you're in the wrong forum to begin with, this is a great time to post in the right forum: forum796. You might want to repost this question there, or you're liable to get a lot of VB6 answers.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top