I am new to C# and QBFC13 code and I'm trying to add a bill from code I found on the intuit developer site under the BillAdd section.
The BillAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString()); is throwing a error:
Invalid GUID format. Must use zero for Custom Fields, or a GUID generated with GuidGen.exe for private data extensions.
I’ve tried:
String guid = System.Guid.NewGuid().ToString("B");
// MessageBox to see that it creates the number
MessageBox.Show("guid", guid);
BillAddRq.ExternalGUID.SetValue(guid);
BillAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString("B"));
And
String guid = System.Guid.NewGuid().ToString("0");
And those throw:
QB Test 8-14-2014.vshost.exe - No Disk "There is no disk in the drive. Please insert a disk into drive F."
How can I resolve these errors?
Using your first string attempt is the correct format for the GUID. I tested using GUID.NewGuid().ToString("B") and was able to get a GUID that works when adding a bill.
Because you're getting an error about there being no disk in the drive, it sounds like something else is causing the error. I would step through the code and find the exact place that causes the error as it probably has nothing to do with the GUID.
Here's a simple example that I did using a sample file in QuickBooks:
QBSessionManager SessionManager = new QBSessionManager();
SessionManager.OpenConnection2("GUIDTest","GUIDTest", ENConnectionType.ctLocalQBD);
SessionManager.BeginSession("", ENOpenMode.omDontCare);
IMsgSetRequest MsgRequest = sessionManager.CreateMsgSetRequest("US", 13, 0);
MsgRequest.Attributes.OnError = ENRqOnError.roeContinue;
IBillAdd add = MsgRequest.AppendBillAddRq();
add.ExternalGUID.SetValue(System.Guid.NewGuid().ToString("B"));
add.VendorRef.FullName.SetValue("A Cheung Limited");
add.TxnDate.SetValue(DateTime.Today);
IExpenseLineAdd line = add.ExpenseLineAddList.Append();
line.AccountRef.FullName.SetValue("Travel & Lodging");
line.Amount.SetValue(100.00);
IResponse response = sessionManager.DoRequests(MsgRequest).ResponseList.GetAt(0);
MessageBox.Show(response.StatusMessage);
Related
I successful Adding image in SQL database using Stream class in that code
Public CN As New ADODB.Connection
Public Emp As New ADODB.Recordset
Public ST As New ADODB.Stream
Emp.Open("Employees", CN, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Emp.AddNew()
ST.Open()
ST.Type = ADODB.StreamTypeEnum.adTypeBinary
ST.LoadFromFile(OpenFileDialog1.FileName)
Emp(19).Value = ST.Read
Emp.Update()
ST.Close()
Emp.Close()
this operation is successful but when I retrieve the database using this Code:
Emp.Open("Select * From Employees Where UserName = '" + TXTSearch.Text + "'", CN)
ST.Open()
ST.Type = ADODB.StreamTypeEnum.adTypeBinary
ST.Write(Emp.Fields(19).Value)
ST.SaveToFile("\temp", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
PICEmployee.Image = Image.FromFile("\temp")
ST.Close()
Emp.Close()
I have a button to show the database grid and it confirm the picture is loaded
but when I tried to fetch the data it stopped in that line
ST.SaveToFile("\temp", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
says Failed to Write I changed the Path got same error, I open the VB as Administrator got same error.
Tip: I didn't send All my Codes in case if something missing but everything about Stream is here
I like to have simple solution I'm still beginner and Need all Help you can give to me, Thanks
I've been getting the following error when trying to write data from my HMI to a MSSQL db using ADODB.recordset with the AddNew/Update Methods. I'm using SQL Server Native Client 11.0 for the connection and Microsoft ActiveX Data Objects 6.0 Library.
Generic VBA Error -2147467259[Microsoft][SQL Server Native Client 11.0][SQL Server]FNGCO,ABCDEFGHI,1000003,2017-04-14,17:00:36:187,FOAML1,A1,,1
If it works this code should write each value to each column in the MSSQL database. I've got very similar code working in another part of the application, but I can't seem to get this working.
What I Have Tried So Far:
Checked against code running in another HMI, everything between the two appears to be identical.
Tried the same connection string with another ADODB.recordset and added data to the db with AddNew/Update.
Checked the database table to make sure all of the data I'm trying to enter fits the column (its not null, max characters not exceeded, etc...)
Here is my code:
On debug, the code halts at sqlrs1.Update.
Option Explicit
Const strSQLNCLI11_1 = "Driver={SQL Server Native Client 11.0};Server=TESTDEMO\SQLEXPRESS;Database=RABPI;Uid=sa;Pwd=testdemo;QueryTimeout=0"'
Private Sub Button1_Released()
On Error GoTo ErrHandler
Dim sqlcn2 As ADODB.Connection
Dim sqlrs1 As ADODB.Recordset
Set sqlcn2 = New ADODB.Connection
Set sqlrs1 = New ADODB.Recordset
sqlcn2.Open strSQLNCLI11_1
sqlrs1.Open "Select * from AT_BW_PRDN ;", _
sqlcn2, adOpenDynamic, adLockPessimistic
sqlrs1.AddNew
sqlrs1("AT_BW_BUS_UNIT") = "FNGCO"
sqlrs1("AT_BW_PID") = "ABCDEFGHI"
sqlrs1("AT_BW_PRDN_AREA") = "FOAML1"
sqlrs1("AT_BW_SHIFT") = "A1"
sqlrs1("AT_BW_ITEM_ID") = "1000007"
sqlrs1("AT_BW_REL") = 0
sqlrs1.Update
Exit Sub
ErrHandler:
LogDiagnosticsMessage "Generic VBA Error" & Err.Number & " " & Err.Description, ftDiagSeverityError, ftDiagAudienceOperator
Set sqlcn2 = Nothing
Set sqlrs1 = Nothing
Exit Sub
End Sub
UPDATE:
I made a test database and re-created the tables I'm trying to write to without any constraints or triggers and the code functioned properly.
I don't see the Unit Price attribute available in the Item Class when it comes to QBD. Its available in QBO. I am trying to download and fill a database using the items entered via Quickbooks desktop version. Can someone help please?
How can I get the Unit Price for an item in Intuit.Ipp.Data.Qbd.Item?
Extra Information Added after comment by Shivan Raptor (7-Nov-2013)
I am having a Quickbooks Pro Trial 2014 UK version installed in my computer. I have created a company file and items for the company. When I create an item I can enter a Price to that item. Quickbooks must be saving it somewhere. I need to access it using the Quickbooks API from my .Net application.
I am interested on the stock items here. I am using Intuit.Ipp.Data.Qbd.Item class to access it. Am I using the right class? If you go to the API documentation the Item class has a field called Unit Price but its not listed when you actually check from the .Net application.
Shivan Raptor wanted the code (8-Nov-2013)
Given below is the code snippet. If you understand the question properly you would realize it cannot give a run time error because you cannot compile a code if you write it with object attributes that are not exposed. And the compiler error is kind of obvious too:
ATTRIBUTE_NAME not present in CLASS_NAME
In this case, ATTRIBUTE_NAME = UnitPrice and CLASS_NAME = Intuit.Ipp.Data.Qbd.Item (this is already there in the first post itself)
The relevant code sample is given below. Its the code behind of an ASP.Net page.
Try
Dim varItemBL As New BL.ItemManagement
'Preparing Query
Dim qbdItemQuery As New Intuit.Ipp.Data.Qbd.ItemQuery
qbdItemQuery.ItemElementName = Intuit.Ipp.Data.Qbd.ItemChoiceType4.StartPage
qbdItemQuery.Item = "1"
qbdItemQuery.ChunkSize = "10"
'Quering Quickbooks Desktop
Dim qbdItems = qbdItemQuery.ExecuteQuery(Of Intuit.Ipp.Data.Qbd.Item)(context).ToList
'Synchronising Items from Quickbooks to MyDigiRep
For i As Integer = 0 To qbdItems.Count - 1
Dim varUnitPrice As Decimal
'Checking whether Unit Price is entered
If qbdItems(i).UnitPrice Is Nothing Then
varUnitPrice = 0
Else
varUnitPrice = qbdItems(i).UnitPrice.Amount
End If
'Synchronising Item with the MyDigiRep database
varItemBL.fnAddItemsAPI(qbdItems(i).Name, "NS", varUnitPrice, _
qbdItems(i).UOMAbbrv, HttpContext.Current.Session("companyID"), _
qbdItems(i).Id.Value)
Next
'Updating UI to display synchronisation results
lblItemSycnStatus.Text = qbdItems.Count & " Item Records Synchronised."
Catch ex As Exception
lblItemSycnStatus.Text = "Item Records Synchronisation Failed."
End Try
The version of the Intuit.Ipp.Data.dll is 2.1.12.0
I need to find or do an inquiry for getting the access point using JUDDI from an already published service. I followed the procedure told in Apache jUDDI: Finding Templates. But it didn't work out and i get the following error from the Tomcat server:
Sep 01, 2012 11:29:58 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
INFO: Application {urn:uddi-org:v3_service}UDDIInquiryService#{urn:uddi-org:v3_service}find_service has thrown exception, unwinding now: org.apache.juddi.v3.error.FatalErrorException: At least one name, categoryBag, find_tModel or tModelBag or name must be supplied
And also the same error is indicated in Netbeans IDE as:
javax.xml.ws.soap.SOAPFaultException: At least one name, categoryBag, find_tModel or tModelBag or name must be supplied
My code snippet is as follows:
FindService fs = new FindService();
fs.setAuthInfo(rootAuthToken.getAuthInfo());
fs.setBusinessKey("uddi:juddi.apache.org:e7180bfb-3c36-451e-86aa-f7605a96587c");
ServiceList sl = inquiry.findService(fs);
ServiceInfos si = sl.getServiceInfos();
GetServiceDetail gsd = new GetServiceDetail();
ServiceDetail sd = inquiry.getServiceDetail(gsd);
BusinessService bs = (BusinessService) sd.getBusinessService();
BindingTemplates bts = bs.getBindingTemplates();
BindingTemplate bt = (BindingTemplate) bts.getBindingTemplate();
AccessPoint ap = bt.getAccessPoint();
wsdlTA.setText(ap.getValue());
Never mind, I got it solved through the Apache JUDDI's project mailing list. Thanks to 秦玉珠 for the help. The code can be as follows:
ServiceList list1=inquiryService.findService(findservice);
GetServiceDetail gsd=new GetServiceDetail();
for(ServiceInfo serviceInfo :list1.getServiceInfos().getServiceInfo()){
gsd.getServiceKey().add(serviceInfo.getServiceKey());
System.out.println(serviceInfo.getServiceKey());
String servicekey=serviceInfo.getServiceKey();
GetServiceDetail getServiceDetail=new GetServiceDetail();
getServiceDetail.setAuthInfo(authinfo);
getServiceDetail.getServiceKey().add(servicekey);
ServiceDetail serviceDetail=inquiryService.getServiceDetail(getServiceDetail);
BusinessService businessservice=serviceDetail.getBusinessService().get(0);
System.out.println("fetched service name:"+businessservice.getName().get(0).getValue());
String bindingkey = businessservice.getBindingTemplates().getBindingTemplate().get(0).getBindingKey();
System.out.println(bindingkey);
GetBindingDetail gbd = new GetBindingDetail();
gbd.setAuthInfo(authinfo);
gbd.getBindingKey().add(bindingkey);
BindingDetail bindingdetail=inquiryService.getBindingDetail(gbd);
BindingTemplate bindingtemplate=bindingdetail.getBindingTemplate().get(0);
String accesspoint=bindingtemplate.getAccessPoint().getValue();
System.out.println(accesspoint);
}
there is a way by which we parse any time input given by user...
here i am taking the input of a connection string from a text file
i am supposed to assume that the user who keeps this string in the text file can be trusted.
but what if he makes a typo a mistake unknowingly, that will cause the coming code to cause exception,
i would like a way to check the string for the correct format, like parse it some way to see if it is the way an connection tring should be, and then possibly use that parsed result.
edit
as requested the sample code i using, and the connection the sqladaptor using
//Connect to a remote instance of SQL Server.
Server srv;
ServerConnection conContext = new ServerConnection();
conContext.ServerInstance = #"A-63A9D4D7E7934\SECOND";
conContext.LoginSecure = false;
conContext.Login = "sa";
conContext.Password = "two";
srv = new Server(conContext);
Response.Write(srv.Information.Version);
//Data Source=A-63A9D4D7E7834\SECOND;Initial Catalog=replicate;User ID=sa;Password=***********
A regular expresion can't validate an incorrect password, user name, or host name, so it is possible for your user to generate a valid string that will still cause an exception.
Also, you can't build a regex that will cover every possible combination of connection arguments.
The only robust solution, would be to wrap the connection code in a try/catch block and provide an appropriate error message.