这是我在 Visual Basic(winform 应用程序)上连接我的项目并触发SELECT STATEMENT
SQLSERVER 的方式,我现在的问题是我不知道这是否与在 JAVA 应用程序上连接我的项目的方式相同。(当然我知道它应该Imports java.sql.*
代替 Imports System.Data.SqlClient
)
Imports System.Data.SqlClient
Try
Dim querystring As String = "SELECT MAX(pIDNo) FROM dbo.Patients"
Using connection As New SqlConnection("Data Source=****;Initial Catalog=****;Persist Security Info=True;User ID=****;Password=****")
Dim command As New SqlCommand(querystring, connection)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader
Dim value = String.Empty
While reader.Read
value = reader.GetString(0)
End While
txtPNumber.Text = Today.Year.ToString().Substring(2, 2) & Today.Month.ToString().PadLeft(2, "0") & (Integer.Parse(value.Substring(4, value.Length - 4)) + 1).ToString("D4")
End Using
Catch ex As Exception
txtPNumber.Text = Today.Year.ToString().Substring(2, 2) & Today.Month.ToString().PadLeft(2, "0") & num.ToString("D4")
End Try
很难理解如何将我的 java 应用程序连接到 SQLSERVER,因为我缺乏关于此类事情的信息。谁能告诉我该怎么做?