[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 994
  • Last Modified:

Operator '&' is not defined for types 'String' and 'System.Windows.Forms.TextBox'

This code snippet below gives me a warning underline on this piece of code  "CREATE DATABASE " & datasetnmTB.

The warning message is:
Operator '&' is not defined for types 'String' and 'System.Windows.Forms.TextBox'

I read through similar errors in the knowledge base but haven't been able to successfully overcome this.

Thank you.
Dim sql As String = "CREATE DATABASE " & datasetnmTB & " ON PRIMARY" + "(Name=test_data, filename = 'C:\program files\maximum insights - cleaner\dataset\mydb_data.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=mydbb_log, filename='C:\program files\maximum insights - cleaner\dataset\" & datasetnmTB & "_log.ldf',size=3," + "maxsize=20,filegrowth=1)"

Open in new window

0
adamchicago
Asked:
adamchicago
1 Solution
 
käµfm³d 👽Commented:
You have to access the Text property of a TextBox in order to get its value.
Dim sql As String = "CREATE DATABASE " & datasetnmTB.Text & " ON PRIMARY" + "(Name=test_data, filename = 'C:\program files\maximum insights - cleaner\dataset\mydb_data.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=mydbb_log, filename='C:\program files\maximum insights - cleaner\dataset\" & datasetnmTB.Text & "_log.ldf',size=3," + "maxsize=20,filegrowth=1)"

Open in new window

0
 
adamchicagoAuthor Commented:
Well that did it....it seems so simple.  I know Excel VBA really well but am still getting up to speed in VB.Net.

Thanks again!
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now