我正在创建一个简单的程序来从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表
发布评论