MySQL/VB.NET(Winform) - How to use correctly @var?How can I prevent SQL injection in PHP?How to output MySQL query results in CSV format?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?How to 'insert if not exists' in MySQL?What is a NullReferenceException, and how do I fix it?How to reset AUTO_INCREMENT in MySQL?How to get the sizes of the tables of a MySQL database?How to import an SQL file using the command line in MySQL?

Did Stalin kill all Soviet officers involved in the Winter War?

Performance of loop vs expansion

Which high-degree derivatives play an essential role?

How to travel between two stationary worlds in the least amount of time? (time dilation)

Versicle and response symbols

Can you use a reaction to affect initiative rolls?

Is there ever a reason not to use Java 8's parallelSort?

Does a reference have a storage location?

what is the meaning of "stock" dilution on the Massive Dev Chart Website?

Why did my leaking pool light trip the circuit breaker, but not the GFCI?

CPLEX exceeds time limit issue

Construction of the word подтвержда́ть

A student "completes" 2-week project in 3 hours and lies about doing it himself

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

"Best practices" for formulating MIPs

What caused the flashes in the video footage of Chernobyl?

How come having a Deathly Hallow is not a big deal?

Was Wolfgang Unzicker the last Amateur GM?

What is the difference between case and adpositions?

Phrasing "it says" or "it reads"

What could a Medieval society do with excess animal blood?

How might boat designs change in order to allow them to be pulled by dragons?

What is -(-2,3,4)?

Pandas merge and fillna



MySQL/VB.NET(Winform) - How to use correctly @var?


How can I prevent SQL injection in PHP?How to output MySQL query results in CSV format?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?How to 'insert if not exists' in MySQL?What is a NullReferenceException, and how do I fix it?How to reset AUTO_INCREMENT in MySQL?How to get the sizes of the tables of a MySQL database?How to import an SQL file using the command line in MySQL?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am developing a sequence in MySQL & VB.NET in which, when deleting a record, the number that identifies it, is deleted and put a sequence of 1 to 'n', the sequence is as follows.



this is the instruccion for MySQL.



SET @rownum=0;
UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name=59999 and id_line.line_no<>0) r
SET t.line_no = r.rownum
WHERE (t.id_line_b = r.id_line_b)


in VB.net I use this



cmdB = New MySqlCommand("SET @rownum=0 UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r ) SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


but VB sends this error




You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_lin' at line 1




Could you help me please in this error?



Updated 1:
This is my string connection.



Public conString As String = "Data Source=server_one;port=3306;Initial Catalog=test_db;User Id=root;password=root;Allow User Variables=True"









share|improve this question
























  • For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

    – Andrew Morton
    Mar 25 at 18:38











  • Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

    – LARC
    Mar 25 at 19:34


















0















I am developing a sequence in MySQL & VB.NET in which, when deleting a record, the number that identifies it, is deleted and put a sequence of 1 to 'n', the sequence is as follows.



this is the instruccion for MySQL.



SET @rownum=0;
UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name=59999 and id_line.line_no<>0) r
SET t.line_no = r.rownum
WHERE (t.id_line_b = r.id_line_b)


in VB.net I use this



cmdB = New MySqlCommand("SET @rownum=0 UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r ) SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


but VB sends this error




You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_lin' at line 1




Could you help me please in this error?



Updated 1:
This is my string connection.



Public conString As String = "Data Source=server_one;port=3306;Initial Catalog=test_db;User Id=root;password=root;Allow User Variables=True"









share|improve this question
























  • For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

    – Andrew Morton
    Mar 25 at 18:38











  • Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

    – LARC
    Mar 25 at 19:34














0












0








0








I am developing a sequence in MySQL & VB.NET in which, when deleting a record, the number that identifies it, is deleted and put a sequence of 1 to 'n', the sequence is as follows.



this is the instruccion for MySQL.



SET @rownum=0;
UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name=59999 and id_line.line_no<>0) r
SET t.line_no = r.rownum
WHERE (t.id_line_b = r.id_line_b)


in VB.net I use this



cmdB = New MySqlCommand("SET @rownum=0 UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r ) SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


but VB sends this error




You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_lin' at line 1




Could you help me please in this error?



Updated 1:
This is my string connection.



Public conString As String = "Data Source=server_one;port=3306;Initial Catalog=test_db;User Id=root;password=root;Allow User Variables=True"









share|improve this question
















I am developing a sequence in MySQL & VB.NET in which, when deleting a record, the number that identifies it, is deleted and put a sequence of 1 to 'n', the sequence is as follows.



this is the instruccion for MySQL.



SET @rownum=0;
UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name=59999 and id_line.line_no<>0) r
SET t.line_no = r.rownum
WHERE (t.id_line_b = r.id_line_b)


in VB.net I use this



cmdB = New MySqlCommand("SET @rownum=0 UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r ) SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


but VB sends this error




You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE id_line t, (SELECT @rownum=:@rownum+1 rownum, id_line.* FROM id_lin' at line 1




Could you help me please in this error?



Updated 1:
This is my string connection.



Public conString As String = "Data Source=server_one;port=3306;Initial Catalog=test_db;User Id=root;password=root;Allow User Variables=True"






mysql vb.net winforms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 19:36







LARC

















asked Mar 25 at 17:52









LARCLARC

12 bronze badges




12 bronze badges












  • For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

    – Andrew Morton
    Mar 25 at 18:38











  • Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

    – LARC
    Mar 25 at 19:34


















  • For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

    – Andrew Morton
    Mar 25 at 18:38











  • Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

    – LARC
    Mar 25 at 19:34

















For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

– Andrew Morton
Mar 25 at 18:38





For a start, I see a semi-colon at the end of SET @rownum=0; but it doesn't appear in the string in the VB.NET code.

– Andrew Morton
Mar 25 at 18:38













Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

– LARC
Mar 25 at 19:34






Yes, the first part of the code is for the database engine, add the semicolon in VB.NET, but the error persists.

– LARC
Mar 25 at 19:34













2 Answers
2






active

oldest

votes


















0














other better way for
create mysql procedure for delete mysql data query



https://www.tutorialspoint.com/What-is-stored-procedure-and-how-can-we-create-MySQL-stored-procedures






share|improve this answer























  • Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

    – LARC
    Mar 25 at 20:06


















0














I found the error, a parenthesis, it was misplaced, this is the correct code.



cmdB = New MySqlCommand("SET @rownum:=0; UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


Thank you everyone for your attention and support.



Regards.






share|improve this answer























  • I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

    – Mary
    Mar 26 at 2:19











  • OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

    – LARC
    Mar 27 at 21:59














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343821%2fmysql-vb-netwinform-how-to-use-correctly-var%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














other better way for
create mysql procedure for delete mysql data query



https://www.tutorialspoint.com/What-is-stored-procedure-and-how-can-we-create-MySQL-stored-procedures






share|improve this answer























  • Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

    – LARC
    Mar 25 at 20:06















0














other better way for
create mysql procedure for delete mysql data query



https://www.tutorialspoint.com/What-is-stored-procedure-and-how-can-we-create-MySQL-stored-procedures






share|improve this answer























  • Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

    – LARC
    Mar 25 at 20:06













0












0








0







other better way for
create mysql procedure for delete mysql data query



https://www.tutorialspoint.com/What-is-stored-procedure-and-how-can-we-create-MySQL-stored-procedures






share|improve this answer













other better way for
create mysql procedure for delete mysql data query



https://www.tutorialspoint.com/What-is-stored-procedure-and-how-can-we-create-MySQL-stored-procedures







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 19:42









Rajesh sureliyaRajesh sureliya

11 bronze badge




11 bronze badge












  • Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

    – LARC
    Mar 25 at 20:06

















  • Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

    – LARC
    Mar 25 at 20:06
















Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

– LARC
Mar 25 at 20:06





Thank you for your contribution, but the error is in VB, in MySQL engine is working fine, anyway I'll try whit the method you propose. Thank you again. Regards.

– LARC
Mar 25 at 20:06













0














I found the error, a parenthesis, it was misplaced, this is the correct code.



cmdB = New MySqlCommand("SET @rownum:=0; UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


Thank you everyone for your attention and support.



Regards.






share|improve this answer























  • I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

    – Mary
    Mar 26 at 2:19











  • OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

    – LARC
    Mar 27 at 21:59
















0














I found the error, a parenthesis, it was misplaced, this is the correct code.



cmdB = New MySqlCommand("SET @rownum:=0; UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


Thank you everyone for your attention and support.



Regards.






share|improve this answer























  • I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

    – Mary
    Mar 26 at 2:19











  • OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

    – LARC
    Mar 27 at 21:59














0












0








0







I found the error, a parenthesis, it was misplaced, this is the correct code.



cmdB = New MySqlCommand("SET @rownum:=0; UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


Thank you everyone for your attention and support.



Regards.






share|improve this answer













I found the error, a parenthesis, it was misplaced, this is the correct code.



cmdB = New MySqlCommand("SET @rownum:=0; UPDATE id_line t, (SELECT @rownum:=@rownum+1 rownum, id_line.* FROM id_line WHERE id_line.line_name='" & TextBox1.Text & "' and id_line.line_no<>0) r SET t.line_no = r.rownum WHERE(t.id_line_b = r.id_line_b)", conn)


Thank you everyone for your attention and support.



Regards.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 0:00









LARCLARC

12 bronze badges




12 bronze badges












  • I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

    – Mary
    Mar 26 at 2:19











  • OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

    – LARC
    Mar 27 at 21:59


















  • I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

    – Mary
    Mar 26 at 2:19











  • OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

    – LARC
    Mar 27 at 21:59

















I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

– Mary
Mar 26 at 2:19





I am glad you found your error but please use parameters. That TextBox1.Text can cause damage to your database. It needs to be sanitized by setting it as the value of a parameter which will be treated as a value not executable code by the database engine.

– Mary
Mar 26 at 2:19













OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

– LARC
Mar 27 at 21:59






OK, I understand, the code was updated whit a variable before the sentence to do the MySQLCommand, is working too!. Thank you so much for your contribution too.

– LARC
Mar 27 at 21:59


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343821%2fmysql-vb-netwinform-how-to-use-correctly-var%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript