Click here to Skip to main content
15,905,233 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCalling function on page from a UserControl Pin
cullyk13-Dec-06 22:10
cullyk13-Dec-06 22:10 
AnswerRe: Calling function on page from a UserControl Pin
DavidNohejl14-Dec-06 2:14
DavidNohejl14-Dec-06 2:14 
GeneralRe: Calling function on page from a UserControl Pin
cullyk14-Dec-06 3:36
cullyk14-Dec-06 3:36 
GeneralRe: Calling function on page from a UserControl Pin
DavidNohejl14-Dec-06 5:25
DavidNohejl14-Dec-06 5:25 
GeneralRe: Calling function on page from a UserControl Pin
cullyk14-Dec-06 5:32
cullyk14-Dec-06 5:32 
AnswerRe: Calling function on page from a UserControl Pin
DavidNohejl14-Dec-06 6:51
DavidNohejl14-Dec-06 6:51 
AnswerRe: Calling function on page from a UserControl Pin
GaryWoodfine 14-Dec-06 7:09
professionalGaryWoodfine 14-Dec-06 7:09 
QuestionSome Problem,Please help me Pin
kishore19@hotmail.com13-Dec-06 21:36
kishore19@hotmail.com13-Dec-06 21:36 
My application needs Exports to Excel and From Excel to Database

for that ,i have used the code

For Export:

Dim mySQLCommand As New SqlCommand
Dim myConnection As New SqlConnection
Dim datagrid1 As New DataGrid
Dim DS As New DataSet
Dim DT As New DataSet

myConnection = New SqlConnection("Password=technologies;Persist Security Info=False;User ID=sa;Initial Catalog=Lims_Demo;Data Source=VISHWA") 'ConfigurationSettings.AppSettings("MyConStr"))
myConnection.Open()
Dim da As New SqlDataAdapter("SELECT top 30 ProductCode,ProductName,GenericName,RetestPeriod FROM Results where status=0", myConnection)
da.Fill(DT)
datagrid1.DataSource = DT
datagrid1.DataBind()
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New Html32TextWriter(tw)
datagrid1.RenderControl(hw)
Response.Write(tw.ToString())
Dim path As String = "C:\...\abc.doc"
Response.AddHeader("content-disposition", "attachment; filename=Worddocument.xls")
Response.End()
'FileStream sourceFile = new FileStream(path, FileMode.Open);
'long FileSize;
'FileSize = sourceFile.Length;
'byte[] getContent = new byte[(int)FileSize];
'sourceFile.Read(getContent, 0, (int)sourceFile.Length);
'sourceFile.Close();
'Response.BinaryWrite(getContent);
'dim SaveFileDialog1 as System.
'If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
' RichTextBox1.SaveFile(SaveFileDialog1.FileName, _
' RichTextBoxStreamType.PlainText)
'End If
myConnection.Close()



the above coding is working very good and giving the required results

but when i am going to Import Excel data to Database

I have used the code, which i found in Msdn help



'---------------------Importing Data From Excel to Database
If Not FILE1.PostedFile.FileName = "" Then
FilePath = FILE1.PostedFile.FileName
End If
'Excel Work Sheet Database Connection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & FilePath & "; " & _
"Extended Properties=Excel 8.0;")
'Select the data from Sheet1 of the workbook.
'MyConnection.Open()
'Dim dt As Table = MyConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null)
Dim f As Array
f = Split(FilePath, "\")
Dim k As Integer = f.Length
Dim str As String = f(k - 1)
Dim filename As String = str.Substring(0, str.LastIndexOf("."))
'str.Split(".xls")
'Dim f1 As Array
'f1 = Split(str, ".")
'Dim str1 As String = f1(f1.Length - 1)
Try
Dim str2 As String = "select * from [EXPnIMP$]"
'Select the data from Sheet1 of the workbook.
'MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
' str2, MyConnection)

''' Select the data from Sheet1 of the workbook.
'MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
' "select * from [" & filename & "$]", MyConnection)
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [" & filename & "$]", MyConnection)



DS = New System.Data.DataSet 'DataSet
MyCommand.Fill(DS) 'Filling The dataset

------------------------------------------------------



it is also working fine,but it is working only for Excel sheet , which i create

it is not working for the excel sheet which i created by using the above code


it is giving the below error,

i think the errror may be in exporting to excel,

when i put google search,it is showing that, file should be exclusive,how can we set exclusive to a file


the error , i am getting is :

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access 97 Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.


kishore
AnswerRe: Some Problem,Please help me Pin
_AK_13-Dec-06 22:10
_AK_13-Dec-06 22:10 
GeneralRe: Some Problem,Please help me Pin
kishore19@hotmail.com14-Dec-06 23:39
kishore19@hotmail.com14-Dec-06 23:39 
QuestionRepeater Control Related Query Pin
param thaker13-Dec-06 20:09
param thaker13-Dec-06 20:09 
QuestionJavascript in datagrid Pin
abulhassan_shock13-Dec-06 20:01
abulhassan_shock13-Dec-06 20:01 
QuestionError while trying to run project Pin
MissionSuccess13-Dec-06 18:37
MissionSuccess13-Dec-06 18:37 
AnswerRe: Error while trying to run project Pin
payback13-Dec-06 19:52
payback13-Dec-06 19:52 
GeneralRe: Error while trying to run project Pin
MissionSuccess13-Dec-06 20:32
MissionSuccess13-Dec-06 20:32 
QuestionRe: Error while trying to run project Pin
just3ala213-Dec-06 19:59
just3ala213-Dec-06 19:59 
AnswerRe: Error while trying to run project Pin
MissionSuccess13-Dec-06 20:29
MissionSuccess13-Dec-06 20:29 
QuestionRe: Error while trying to run project Pin
Imran Khan Pathan13-Dec-06 20:38
Imran Khan Pathan13-Dec-06 20:38 
QuestionProblem Uploading an Image twice [modified] Pin
Britney S. Morales13-Dec-06 9:57
Britney S. Morales13-Dec-06 9:57 
AnswerRe: Problem Uploading an Image twice Pin
Kschuler13-Dec-06 10:36
Kschuler13-Dec-06 10:36 
AnswerRe: Problem Uploading an Image twice Pin
saravanan0514-Dec-06 9:10
saravanan0514-Dec-06 9:10 
QuestionASP:MENU and black caret for submenus Pin
Leo Smith13-Dec-06 8:28
Leo Smith13-Dec-06 8:28 
AnswerRe: ASP:MENU and black caret for submenus Pin
minhpc_bk13-Dec-06 13:42
minhpc_bk13-Dec-06 13:42 
GeneralRe: ASP:MENU and black caret for submenus Pin
Leo Smith14-Dec-06 12:35
Leo Smith14-Dec-06 12:35 
QuestionPassing an Object between pages. Pin
legionnaire13-Dec-06 5:50
legionnaire13-Dec-06 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.