使用文本框从vb.net重命名mysql表

编程入门 行业动态 更新时间:2024-10-24 04:32:31
本文介绍了使用文本框从vb重命名mysql表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个简单的程序来从vb创建一个mysql表并通过用户选择重命名。 i在创建表时取得了成功这很简单,但是如何重命名表来自textbox折磨了我很多。 这里是创建表的代码

试试 cnn.Open() Dim query As 字符串 query = CREATE TABLE best.new(id INT NOT NULL,名称VARCHAR(45)NULL,日期DATETIME NULL,PRIMARY KEY(id)); cmd = 新 MySqlCommand(query,cnn) reader = cmd.ExecuteReader MessageBox.Show( table创建) cnn.Close()

i尝试使用此代码重命名但没有成功。 ...!已经实现了 i尝试了一些,但它给出了错误 i想要从用户给出的id重命名

Dim 重命名作为 字符串 Rename =( RENAME TABLE new to TextBox1.Text) cmd = 新 MySqlCommand(重命名,cnn) reader = cmd.ExecuteReader MessageBox.Show( 重命名为 cnn.Close()

请帮我找出来

解决方案

试试这个(在To之后添加 Space 并添加& ):

Dim 重命名 As 字符串 重命名=( RENAME TABLE new to& TextBox1.Text) cmd = 新 MySqlCommand(重命名,cnn) reader = cmd.ExecuteReader MessageBox.Show( 重命名为 cnn.Close()

我希望这会对你有所帮助。 :)

添加空格...

重命名=( RENAME TABLE new To TextBox1.Text)

成为

Rename =( RENAME TABLE new to TextBox1 .Text)

但你最好小心点。 你离开你的整个数据库对SQL注入广泛开放。

尝试使用

Rename = RENAME TABLE best.new TO& TextBox1.Text

i am making a simple program to create a mysql table from vb and renaming it by user choice. i got success in creating the table it is quite simple but how to rename a table from textbox tortured me a lot. here's the code to create a table

Try cnn.Open() Dim query As String query = "CREATE TABLE best.new (id INT NOT NULL, name VARCHAR(45) NULL, date DATETIME NULL, PRIMARY KEY (id));" cmd = New MySqlCommand(query, cnn) reader = cmd.ExecuteReader MessageBox.Show("table created") cnn.Close()

i tried to rename it using this code but no success....! achieved yet i tried few more but it gives error i want to rename it from the "id" given by the user

Dim rename As String Rename = ("RENAME TABLE new To" TextBox1.Text) cmd = New MySqlCommand(Rename, cnn) reader = cmd.ExecuteReader MessageBox.Show("renamed") cnn.Close()

please help me to find it out

解决方案

Try this One (Added Space after To and added &):

Dim rename As String Rename = ("RENAME TABLE new To " & TextBox1.Text) cmd = New MySqlCommand(Rename, cnn) reader = cmd.ExecuteReader MessageBox.Show("renamed") cnn.Close()

I hope this will help you. :)

Add a space...

Rename = ("RENAME TABLE new To" TextBox1.Text)

Becomes

Rename = ("RENAME TABLE new To " TextBox1.Text)

But you had better be damn careful. You leave your whole DB wide open to SQL Injection with this.

try with

Rename = "RENAME TABLE best.new TO " & TextBox1.Text

更多推荐

使用文本框从vb.net重命名mysql表

本文发布于:2023-11-04 05:26:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   重命名   net   vb   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!