NEED HELP~!
I want to create a openfiledialog and allow user to choose which exel file to be imported into the server but this error keep coming "ODBC--connection to '{SQL Server}'TGT102 failed".
Thank you so much~~
PS. I am just a beginner of vb.net. So would u pls tell me the solution in detail?
THANKS~~~!!

Recommended Answers

All 3 Replies

Please provide us the connectionstrings and the code where the error occurs.

Try


Dim sqlstm2 As String = "truncate table fodmast"
ObjAcc.ExecNonquery(sqlstm2)
Dim sqlstm3 As String = "truncate table special_spec_order"
ObjAcc.ExecNonquery(sqlstm3)

Dim sqlstm As String = "drop table " & txtInsertedTableName.Text & ""
ObjAcc.ExecNonquery(sqlstm)
Catch ex As Exception

End Try

Try

Dim ExcelPath As String = txtexcelPath.Text.ToLower()
Dim Ext As String = _
ExcelPath.Substring(ExcelPath.LastIndexOf(".") + 1)
If File.Exists(ExcelPath) AndAlso (Ext.Equals("xls") _
Or Ext.Equals("xlsx")) Then
dm.importToServer(OpenFileDialog1.FileName, txtserver.Text, txtDbName.Text, txtusername.Text, txtpassword.Text, txtInsertedTableName.Text)
ProgressBar1.Visible = False
'MessageBox.Show("File imported successfully")
End If
Catch ex As Exception
ProgressBar1.Visible = False
MessageBox.Show(ex.Message)
Exit Sub
End Try
-------------------------------------------------------------------------
here is the connection strings.
Dim ExceCon As String = _
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
ExcelPath & "; Extended Properties=Excel 8.0"

Try this for your connection string for Excel

"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" & filename & ";"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.