Control Bartender Involve Database Using C# 追蹤

0
Avatar
Legacy Poster

Hi there.I'm using Bartender Automation enterprise 9.4 as well as Microsoft Visual Studio 2005 to help me on my project.

I'm using C# language to design a program and controlling bartender. When it prints,it will call the bartender format and prints out the label that i desire.I have done this part and it works perfectly.

But,what if my bartender involves connect to database(in my case,which is SQL server 2000) to get the data?
Do i need to set the connection on my C# program or the bartender will connect itself when the program is running?

Maybe some one can guide me what can i do starting from this part?
I need to like checking the input from user,check whether it's in database or not.
If so,it will return another field data which is on the same row.
If not, a validation message will appear.That's all.

Thanks.Any help would be really appreciated.

4 意見

0
Avatar
Susan Chen
版主
評論操作 永久連結

Dear Tbzserge :


You setup the database connection inside Bartender: File-> Database Connection Setup. In ActiveX, you can reference Bartender Help-> Automating Bartender-> Automation with ActiveX-> Examples using ActiveXAutomation-> Automating Database Printing in C#

//Declare a BarTender application variable

BarTender.Application btApp;

//Declare a BarTender format variable

BarTender.Format btFormat;

//Declare a BarTender database variable

BarTender.Database btDb;

//Instantiate a BarTender application variable

btApp = new BarTender.ApplicationClass();

//Open the BarTender label format

btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");

//Select the database

btDb = btFormat.Databases.GetDatabase(1);

//Set the SQL statement

btDb.OLEDB.SQLStatement = "SELECT * FROM 'Customers' WHERE 'Name'='Frank Wild'";


You can extract data from database field or show some message depend on your result.



Hope it helps



Thanks!
0
Avatar
Legacy Poster
評論操作 永久連結

Hi Susan,

Actually, i still haven't get myself clear how to retrieve the data from the database (which is connected to bartender) using programming language.

I have tried the code which i refer to bartender ActiveX Automation White Paper.It works perfectly on how to call bartender format and print.

I have done a small test to help me do so.

I have created 2 button,one is call cmdCheck and another one is cmdPrint and 1 textbox call txt1. My database name is Database1 ,table name is Solder_Paste.

I just want to have a test when clicking the check button,it will run the syntax and search from the table and return the result in txt1 and print it when print button is clicked.I have checked the SQL syntax in SQLserver.It works fine.

[code]
private void cmdCheck_Click(object sender, EventArgs e)
{
BarTender.Database btDb;

btDb = btFormat.Databases.GetDatabase(1);
btDb.OLEDB.SQLStatement = "SELECT 'PartNumber' FROM 'Solder_Paste' WHERE 'GRNNumber' = '1234567'";
txt1.Text = btDb.OLEDB.SQLStatement;
}

private void cmdPrint_Click(object sender, EventArgs e)
{
btFormat = btApp.Formats.Open("C:\\Documents and Settings\\Desktop\\vb3\\Format1.btw", false, "");
btFormat.SetNamedSubStringValue("testing", txt1.Text);
btFormat.Print("Job1", true, -1, out btMsgs);
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges);
}
[/code]

Any help would be really appreciated.Thanks.
0
Avatar
Legacy Poster
評論操作 永久連結

Hi 
 
Please i need help I am using bartender full suit 10.1 

in below code when i assign the value of "btDataBase.ODBC.Password" it cann't got it but in case of "btDataBase.ODBC.UserId" or "this.btDataBase.ODBC.SQLStatement" there values changed Please help me in this i am new in this..
 
 
        btDataBase =btFormat.Databases.GetDatabase(1);
        btDataBase.ODBC.UserId = mUserID;
        btDataBase.ODBC.Password = mPassword;
        this.btDataBase.ODBC.SQLStatement = "SELECT * from ScannedData WHERE PackingID='" + l_PackingID + "'";
        this.btFormat.PrintOut();
 
0
Avatar
Domingo Rodriguez
版主
評論操作 永久連結

Tbzserge,

 

When you run the cmdCheck_Click and cmdPrint_Click, what is the value for "testing" when it does get printed?

 

I'm not 100% sure of what you're wishing to achieve. If you just want BarTender to connect to the database, perform an SQL Statement (or assigning a query prompt value), then the example Susan already sent you is the one to be used (to be followed by the Print() method if you're wishing to print those labels which result from applying the SQL Statement / query prompt value). If you're still having issues, please describe in more detail what is going on exactly.

 

By the way, if you're using C#.Net, you would be better make use of the .NET SDKs

登入寫評論。