- I need to prompt the user to input an Account Number which is 8 digits long. It needs to open the sql database to check the acc number.
- Need to use an appropriate class to store the transaction records.
- Create a doubly linked list using the LinkedList(of T) generic to load it with transaction details from the sql Transactions table with the appropriate account number.
- Display the transactions to the user.
So, what I have so far to me seems right, what I'm having problems with is. I am getting a SQL Exception(A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified))
If anyone could provide me with some information, that would be much appriciated.
Public Class Accounts Public Sub LoadData() Dim value As Integer value = InputBox("Enter your 8 Digit Account Number", "Account Number", 0) 'InputBox for Account Number Dim account As New LinkedList(Of Transactions)() ' doubly linked list Dim conn As New SqlConnection("Data Source=(Server)\sqlexpress; Initial Catalog=Library; Integrated Security=True")'sql connection object. Is that how it should be? Dim cmd As New SqlCommand("Select * From [Transactions] Where AccountNo = " & value, conn)'Search sql database for account number conn.Open() Dim reader As SqlDataReader = cmd.ExecuteReader While (reader.Read()) Dim theAccount As New Transactions(reader.GetInt32(0), reader.GetDateTime(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4)) account.AddFirst(theAccount) lbOutput.Items.Add(theAccount) End While reader.Close() conn.Close() End Sub Private Sub btnExecute_Click(sender As System.Object, e As System.EventArgs) Handles btnExecute.Click LoadData() End Sub End Class Public Class Transactions 'Variables of the Transaction Table Created Dim AccountNo As Integer Dim tDate As Date Dim Description As String Dim DebCard As String Dim Amount As Integer Public Sub New(ByVal AccNo As Integer, ByVal Tdate As Date, ByVal Descrip As String, ByVal Card As String, ByVal amount As Integer) 'constructor Me.AccountNo = AccNo Me.tDate = Tdate Me.Description = Descrip Me.DebCard = Card Me.Amount = amount End Sub End Class