The DataAdapter.SelectCommand property needs to be initialized - ado.net

I want to save the modifications I made to a DataSet into the DataBase, but I got this error:
The DataAdapter.SelectCommand property needs to be initialized
This is the code I wrote:
dr = dt.NewRow
dr(0) = t1.Text
dr(1) = t2.Text
dr(2) = t3.Text
dr(3) = d1.Value
dt.Rows.Add(dr)
da.InsertCommand = cb.GetInsertCommand()
da.Update(ds, "stagiaire")
MsgBox("ajout effectu!")
dr is a DataRow / dt is a DataTable / da is a SqlDataAdapter / cb is a SqlCommandBuilder / ds is a DataSet
But when I changed this line : da.InsertCommand = cb.GetInsertCommand() with : cb = New SqlCommandBuilder(da) it worked.
So why the first code I used it didn't worked !

Either you do it like this
dr = dt.NewRow
dr(0) = t1.Text
dr(1) = t2.Text
dr(2) = t3.Text
dr(3) = d1.Value
dt.Rows.Add(dr)
SqlComand cmd=new SqlCommand("insert query",conn)
da.InsertCommand = cmd
da.Update(ds, "stagiaire")
MsgBox("ajout effectu!")
OR
dr = dt.NewRow
dr(0) = t1.Text
dr(1) = t2.Text
dr(2) = t3.Text
dr(3) = d1.Value
dt.Rows.Add(dr)
SqlCommandBuilder cb=new SqlCommandBuilder (da)
da.InsertCommand = cb.GetInsertCommand()
da.Update(ds, "stagiaire")
MsgBox("ajout effectu!")

Related

bypass 'google before you continue' pop-up

My code:
import pandas
import requests
from bs4 import BeautifulSoup
from pywebio.input import *
from pywebio.output import *
from time import sleep
from pywebio import start_server
print("News web application successfully started!")
def app():
request = requests.get("https://news.google.com/topics/CAAqRggKIkBDQklTS2pvUVkyOTJhV1JmZEdWNGRGOXhkV1Z5ZVlJQkZRb0lMMjB2TURKcU56RVNDUzl0THpBeFkzQjVlU2dBUAE/sections/CAQqSggAKkYICiJAQ0JJU0tqb1FZMjkyYVdSZmRHVjRkRjl4ZFdWeWVZSUJGUW9JTDIwdk1ESnFOekVTQ1M5dEx6QXhZM0I1ZVNnQVAB?hl=en-US&gl=US&ceid=US%3Aen")
content = BeautifulSoup(request.content, 'html.parser')
find = content.find('div', class_='ajwQHc BL5WZb')
#open('test.html', 'w').write(findstr.find)
h3 = find.find_all('h3')
time = find.find_all('time')
link = find.find_all('article')#.find_all('a').get('href').replace('.', '')
result = []
#print('https://news.google.com' + link)
#put_html('<table border="1" width="100%" cellpadding="5">')
source = find.find_all('a', {'data-n-tid' : '9'})
time = find.find_all('time')
textoutput = []
textoutput1 = []
textoutput2 = []
takeoutput3 = []
#writer = open('news.csv', 'w')
#writer1 = csv.writer(writer, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for text in h3:
a1 = text.text
textoutput.append(a1)
for text2 in source:
a3 = text2.text
textoutput1.append(a3)
for text1 in time:
a5 = text1.text
textoutput2.append(a5)
#for result in link:
# alinks = result.find_all('a')
# alinks1 = []
# for alinks1 in alinks:
# alinks2 = alinks1.get('href')
# alinksreplace = str(alinks2)
# alinksreplace1 = alinksreplace.replace(".", "")
# alinksreplace2 = alinksreplace1.replace("None", "")
#
# if (alinksreplace2 != ''):
# if "publications" not in alinksreplace2:
# a = "https://news.google.com" + alinksreplace2
# takeoutput3.append(a)
pandas.set_option('display.max_colwidth', None)
frame = {'Title':textoutput, 'Time':textoutput2, 'Source' : textoutput1}
frame1 = pandas.DataFrame(frame)
#frame2 = {'Link' : takeoutput3}
#frame3 = pandas.DataFrame(frame2)
frametostring = frame1.to_string(index=False)
#frametostring1 = frame3.to_string(index=False)
#print(frametostring)
put_code(frametostring)
#put_code(frametostring1)
#writer1.writerow([textoutput, textoutput1, textoutput2])
start_server(app, 82)
it worked fine but today Google update something and now it don't start. And it's because Google add before you continue pop-up. How I can bypass this so my script continue to work?
If it was Selenium I've just clicked the button but here I don't know what to do
Thanks you helping!

Quartz.net can't connect to Postgres DB

Here is my config:
["quartz.jobStore.dataSource"] = "default",
["quartz.jobStore.tablePrefix"] = "QRTZ_",
["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.PostgreSQLDelegate, Quartz",
["quartz.dataSource.default.provider"] = "Npgsql",
["quartz.dataSource.default.connectionString"] = #"User ID=ttt;Password=xxx;Host=ttt.postgres;Port=5432;Database=ttt;"
Exception:
Could not parse property 'dataSource' into correct data type: No writable property 'DataSource' found
I've been trying different things for over an hour, the docs don't really help (slim on the examples front) and I've tried to dig through the Quartz.Net source but no luck :/
Adding this seems to have fixed it - i'm not 100% up and running but I have gotten further...
properties["quartz.scheduler.instanceName"] = "SonatribeScheduler";
properties["quartz.scheduler.instanceId"] = "instance_one";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "10";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz";
properties["quartz.jobStore.useProperties"] = "false";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";

How to remove the following character "/" from service path

Good Morning!
Currently I have set up my structure in Fiware saving my historical records in MongoDB, for this I have been using Mlab as a hosting.
I attache the configuration file of my agent, the problem comes in that due to the mandatory character "/" of the service path I can not access the generated historical data, since it is a character not allowed for collections in MongoDB.
agent_1.conf
cygnus-ngsi.sources = http-source
cygnus-ngsi.sinks = mongo-sink
cygnus-ngsi.channels = mongo-channel
cygnus-ngsi.sources.http-source.channels = mongo-channel
cygnus-ngsi.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnus-ngsi.sources.http-source.port = 5050
cygnus-ngsi.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
cygnus-ngsi.sources.http-source.handler.notification_target = /notify
cygnus-ngsi.sources.http-source.handler.default_service = default
cygnus-ngsi.sources.http-source.handler.default_service_path = /sevilla
cygnus-ngsi.sources.http-source.handler.events_ttl = 2
cygnus-ngsi.sources.http-source.interceptors = ts
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp
cygnus-ngsi.sinks.mongo-sink.type = com.telefonica.iot.cygnus.sinks.NGSIMongoSink
cygnus-ngsi.sinks.mongo-sink.channel = mongo-channel
cygnus-ngsi.sinks.mongo-sink.enable_encoding = false
cygnus-ngsi.sinks.mongo-sink.enable_grouping = false
cygnus-ngsi.sinks.mongo-sink.enable_name_mappings = false
cygnus-ngsi.sinks.mongo-sink.enable_lowercase = false
cygnus-ngsi.sinks.mongo-sink.data_model = dm-by-service-path
cygnus-ngsi.sinks.mongo-sink.attr_persistence = row
cygnus-ngsi.sinks.mongo-sink.mongo_hosts = ds******.mlab.com:35866
cygnus-ngsi.sinks.mongo-sink.mongo_username = my_user
cygnus-ngsi.sinks.mongo-sink.mongo_password = ********
cygnus-ngsi.sinks.mongo-sink.db_prefix = sth_
cygnus-ngsi.sinks.mongo-sink.collection_prefix = sth_
cygnus-ngsi.sinks.mongo-sink.batch_size = 1
cygnus-ngsi.sinks.mongo-sink.batch_timeout = 30
cygnus-ngsi.sinks.mongo-sink.batch_ttl = 10
cygnus-ngsi.sinks.mongo-sink.data_expiration = 0
cygnus-ngsi.sinks.mongo-sink.collections_size = 0
cygnus-ngsi.sinks.mongo-sink.max_documents = 0
cygnus-ngsi.sinks.mongo-sink.ignore_white_spaces = true
cygnus-ngsi.channels.mongo-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.mongo-channel.capacity = 1000
cygnus-ngsi.channels.mongo-channel.transactionCapacity = 100
Is there any way for Cygnus to remove the "/" character from the service path?
Error: http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9827048captura-de-pantalla.png
SOLUTION: You just have to change the enconding to true in the agent configuration
cygnus-ngsi.sinks.mongo-sink.enable_encoding = true
Thank you very much!

Select and update a PostgreSQL in the same query in order to optimize

I am trying to create a query to dynamically update some values from a table Y from a table X.
I'm currenly dealing with a DB that hosts 10kk rows and I would like to optimize the amount of time of the processing.
Select:
SELECT cycle_completa.numcycle AS actual_cycle,
min(cycle_completa.pump1pre) AS min_pump1pre,
min(cycle_completa.pump2pre) AS min_pump2pre,
min(cycle_completa.pump3pre) AS min_pump3pre,
min(cycle_completa.slidevel) AS min_slidevel,
min(cycle_completa.slidepos) AS min_slidepos,
min(cycle_completa.slideforce) AS min_slideforce,
min(cycle_completa.slideservopilotpre) AS min_slideservopilotpre,
min(cycle_completa.slidecentralpre) AS min_slidecentralpre,
min(cycle_completa.slidelateralpre) AS min_slidelateralpre,
min(cycle_completa.slideringpre) AS min_slideringpre,
min(cycle_completa.slidepistonpre) AS min_slidepistonpre,
min(cycle_completa.slidey42pre) AS min_slidey42pre,
min(cycle_completa.cushionforce) AS min_cushionforce,
min(cycle_completa.cushionservopilotpre) AS min_cushionservopilotpre,
min(cycle_completa.cushionpistonpre) AS min_cushionpistonpre,
min(cycle_completa.cushionringpre) AS min_cushionringpre,
min(cycle_completa.pfillaccumpre) AS min_pfillaccumpre,
min(cycle_completa.pfillcentralpre) AS min_pfillcentralpre,
min(cycle_completa.pfilllateralpre) AS min_pfilllateralpre,
min(cycle_completa.pfillunlockingpre) AS min_pfillunlockingpre,
min(cycle_completa.reducedauxpumppre) AS min_reducedauxpumppre,
min(cycle_completa.tankoiltemp) AS min_tankoiltemp
FROM cycle_completa
WHERE slidestage = 17
GROUP BY cycle_completa.numcycle
UPDATE:
UPDATE cycle_parametros
SET seg3_min_valor_fmant_pump1pre = min_pump1pre,
seg3_min_valor_fmant_pump2pre = min_pump2pre,
seg3_min_valor_fmant_pump3pre = min_pump3pre,
seg3_min_valor_fmant_slidevel = min_slidevel,
seg3_min_valor_fmant_slidepos = min_slidepos,
seg3_min_valor_fmant_slideforce = min_slideforce,
seg3_min_valor_fmant_slideservopilotpre = min_slideservopilotpre,
seg3_min_valor_fmant_slidecentralpre = min_slidecentralpre,
seg3_min_valor_fmant_slidelateralpre = min_slidelateralpre,
seg3_min_valor_fmant_slideringpre = min_slideringpre,
seg3_min_valor_fmant_slidepistonpre = min_slidepistonpre,
seg3_min_valor_fmant_slidey42pre = min_slidey42pre,
seg3_min_valor_fmant_cushionforce = min_cushionforce,
seg3_min_valor_fmant_cushionservopilotpre = min_cushionservopilotpre,
seg3_min_valor_fmant_cushionpistonpre = min_cushionpistonpre,
seg3_min_valor_fmant_cushionringpre = min_cushionringpre,
seg3_min_valor_fmant_pfillaccumpre = min_pfillaccumpre,
seg3_min_valor_fmant_pfillcentralpre = min_pfillcentralpre,
seg3_min_valor_fmant_pfilllateralpre = min_pfilllateralpre,
seg3_min_valor_fmant_pfillunlockingpre = min_pfillunlockingpre,
seg3_min_valor_fmant_reducedauxpumppre = min_reducedauxpumppre,
seg3_min_valor_fmant_tankoiltemp = min_tankoiltemp
WHERE numcycle = actual_cycle
Thank you!
The following query should work:
WITH selected as (
SELECT cycle_completa.numcycle AS actual_cycle,
min(cycle_completa.pump1pre) AS min_pump1pre,
min(cycle_completa.pump2pre) AS min_pump2pre,
min(cycle_completa.pump3pre) AS min_pump3pre,
min(cycle_completa.slidevel) AS min_slidevel,
min(cycle_completa.slidepos) AS min_slidepos,
min(cycle_completa.slideforce) AS min_slideforce,
min(cycle_completa.slideservopilotpre) AS min_slideservopilotpre,
min(cycle_completa.slidecentralpre) AS min_slidecentralpre,
min(cycle_completa.slidelateralpre) AS min_slidelateralpre,
min(cycle_completa.slideringpre) AS min_slideringpre,
min(cycle_completa.slidepistonpre) AS min_slidepistonpre,
min(cycle_completa.slidey42pre) AS min_slidey42pre,
min(cycle_completa.cushionforce) AS min_cushionforce,
min(cycle_completa.cushionservopilotpre) AS min_cushionservopilotpre,
min(cycle_completa.cushionpistonpre) AS min_cushionpistonpre,
min(cycle_completa.cushionringpre) AS min_cushionringpre,
min(cycle_completa.pfillaccumpre) AS min_pfillaccumpre,
min(cycle_completa.pfillcentralpre) AS min_pfillcentralpre,
min(cycle_completa.pfilllateralpre) AS min_pfilllateralpre,
min(cycle_completa.pfillunlockingpre) AS min_pfillunlockingpre,
min(cycle_completa.reducedauxpumppre) AS min_reducedauxpumppre,
min(cycle_completa.tankoiltemp) AS min_tankoiltemp
FROM cycle_completa
WHERE slidestage = 17
GROUP BY cycle_completa.numcycle
)
UPDATE cycle_parametros cp
SET cp.seg3_min_valor_fmant_pump1pre = s.min_pump1pre,
cp.seg3_min_valor_fmant_pump2pre = s.min_pump2pre,
cp.seg3_min_valor_fmant_pump3pre = s.min_pump3pre,
cp.seg3_min_valor_fmant_slidevel = s.min_slidevel,
cp.seg3_min_valor_fmant_slidepos = s.min_slidepos,
cp.seg3_min_valor_fmant_slideforce = s.min_slideforce,
cp.seg3_min_valor_fmant_slideservopilotpre = s.min_slideservopilotpre,
cp.seg3_min_valor_fmant_slidecentralpre = s.min_slidecentralpre,
cp.seg3_min_valor_fmant_slidelateralpre = s.min_slidelateralpre,
cp.seg3_min_valor_fmant_slideringpre = s.min_slideringpre,
cp.seg3_min_valor_fmant_slidepistonpre = s.min_slidepistonpre,
cp.seg3_min_valor_fmant_slidey42pre = s.min_slidey42pre,
cp.seg3_min_valor_fmant_cushionforce = s.min_cushionforce,
cp.seg3_min_valor_fmant_cushionservopilotpre = s.min_cushionservopilotpre,
cp.seg3_min_valor_fmant_cushionpistonpre = s.min_cushionpistonpre,
cp.seg3_min_valor_fmant_cushionringpre = s.min_cushionringpre,
cp.seg3_min_valor_fmant_pfillaccumpre = s.min_pfillaccumpre,
cp.seg3_min_valor_fmant_pfillcentralpre = s.min_pfillcentralpre,
cp.seg3_min_valor_fmant_pfilllateralpre = s.min_pfilllateralpre,
cp.seg3_min_valor_fmant_pfillunlockingpre = s.min_pfillunlockingpre,
cp.seg3_min_valor_fmant_reducedauxpumppre = s.min_reducedauxpumppre,
cp.seg3_min_valor_fmant_tankoiltemp = s.min_tankoiltemp
FROM selected AS s
WHERE cp.numcycle = s.actual_cycle

Paypal DoDirectPaymentRequest returning NULL

I am using Paypal's classic API to do a Direct Payment. Here's the code:
require('merchant-sdk-php-master/samples/PPBootStrap.php');
$logger = new PPLoggingManager('DoDirectPayment');
$address = new AddressType();
$address->Name = $full_name;
$address->Street1 = $address_1;
$address->Street2 = $address_2;
$address->CityName = $city;
$address->StateOrProvince = $province;
$address->PostalCode = $postal_code;
$address->Country = $country;
$address->Phone = $phone;
$paymentDetails = new PaymentDetailsType();
$paymentDetails->ShipToAddress = $address;
$paymentDetails->OrderTotal = new BasicAmountType('CAD', $amount);
$personName = new PersonNameType();
$personName->FirstName = $first_name;
$personName->LastName = $last_name;
$payer = new PayerInfoType();
$payer->PayerName = $personName;
$payer->Address = $address;
$payer->PayerCountry = $country;
$cardDetails = new CreditCardDetailsType();
$cardDetails->CreditCardNumber = $card_number;
$cardDetails->CreditCardType = $card_type;
$cardDetails->ExpMonth = $expiry_month;
$cardDetails->ExpYear = $expiry_year;
$cardDetails->CVV2 = $cvv;
$cardDetails->CardOwner = $payer;
$ddReqDetails = new DoDirectPaymentRequestDetailsType();
$ddReqDetails->CreditCard = $cardDetails;
$ddReqDetails->PaymentDetails = $paymentDetails;
$ddReqDetails->PaymentAction = 'Sale';
$ddReqDetails->IPAddress = $ip_address;
$ddReqDetails->ReturnFMFDetails = true;
$doDirectPaymentReq = new DoDirectPaymentReq();
$doDirectPaymentReq->DoDirectPaymentRequest = new DoDirectPaymentRequestType($ddReqDetails);
$logger->info("created doDirectPaymentReq Object");
$paypalService = new PayPalAPIInterfaceServiceService();
try{
$doDirectPaymentResponse = $paypalService->DoDirectPayment($doDirectPaymentReq);
var_dump($doDirectPaymentResponse);
}
catch (Exception $ex){
var_dump($ex);
}
This is the object it returns:
object(DoDirectPaymentResponseType)#84 (15) { ["Amount"]=> NULL ["AVSCode"]=> NULL ["CVV2Code"]=> NULL ["TransactionID"]=> NULL ["PendingReason"]=> NULL ["PaymentStatus"]=> NULL ["FMFDetails"]=> NULL ["ThreeDSecureResponse"]=> NULL ["PaymentAdviceCode"]=> NULL ["Timestamp"]=> NULL ["Ack"]=> NULL ["CorrelationID"]=> NULL ["Errors"]=> NULL ["Version"]=> NULL ["Build"]=> NULL } ­
I'm Canadian so I can't use the new API's because they're not available here yet. I'm stuck with the classic API. Why am I getting this result?
Any help is appreciated!
For some reason, yesterday I was getting an object of NULL values. However, today I am getting an error message. I fixed the error and received a success.
Why it was showing me the error message today and not yesterday, I do not know. I never changed any of the code so it must have been something on Paypal's end.
Still have no idea what was wrong, but that's that.