Home > Net >  The ConnectionString property has not been initialized
The ConnectionString property has not been initialized

Time:03-27

1. The app. Con code




2, the button code
Public da As SqlDataAdapter
Public ds As the DataSet
Public dt As DataTable
Public strConnStr As String=ConfigurationManager. AppSettings (" SqlserverConnString ")
Public conn As SqlClient. SqlConnection=New SqlClient. SqlConnection (strConnStr)

Dim sqltxt1 As String
Sqltxt1="select * from hz1 where demand quantity & lt;> The arrival of the goods quantity and project USES & lt;> 'water making raw materials and DatePart (yyyy, [date])=' "& amp; Y & amp; "' order by date
"Da=New SqlDataAdapter (sqltxt1, conn.)
Dt=New DataTable
Da. The Fill (dt)
DataGridView1. The DataSource=dt
Test environment problem, exe the ConnectionString property has not been initialized, after the great god, please give directions!!!!!!!!!!

CodePudding user response:

Public strConnStr As String=ConfigurationManager. AppSettings (" SqlserverConnString "). The value (plus the)

CodePudding user response:

reference 1st floor jhonsonzhang response:
Public strConnStr As String=ConfigurationManager. The AppSettings (" SqlserverConnString "). The value (plus the)

Added value that are not members of the string

CodePudding user response:

Public strConnStr As String=ConfigurationManager. AppSettings (" SqlserverConnString "), delete directly write the connection String,
Public Const StrConnStr="Initial Catalog=jihua; The Data Source=10.192.112. * * *; User ID=ZJZXM; Password=111111
"

CodePudding user response:

The inside of the configer key can be deleted,
  • Related