Here are my codes:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim SoItem As DataSet = New DataSet
Dim ODBCConnection As New OdbcConnection("dsn=SBT")
Try
Dim MyAdapter As OdbcDataAdapter
MyAdapter = New OdbcDataAdapter("select distinct glsale from sotran01", ODBCConnection)
MyAdapter.Fill(SoItem, "sotran01")
ODBCConnection.Close()
Label1.Text = SoItem.Tables("sotran01").Rows(0)("glsale").ToString
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
This is running on Window 2008 Server 64bit and the ODBC driver (MS FoxPro VFP Driver) is installed in odbcad32.
I was able to read from the table in debug mode but not in release.
Thank you in advance for your help.
Thank you.
Michael
In 64 bit systems there are two odbcad32: one for 32 bit applications (c:\windows\syswow64) and one for 64 bit applications (c:\windows\system32). Make sure your DSN is visible in both and try again.
Related
Partial Class Default3
Inherits System.Web.UI.Page
Dim connectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings("strCon").ToString & Server.MapPath("~/WriteReadData/betanewdb.mdb")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As New System.Data.OleDb.OleDbConnection(connectionString)
Dim qry As String = "SELECT [Year], Kinnow, Orange, Lemon, Mango, Litchi, Guava, Pear, Plum, Grape, Bair, Peach, Unit FROM Agriculture_Area_Under_Fruits "
Dim adp As New OleDbDataAdapter(qry, con)
Dim ds As DataTable = New DataTable()
adp.Fill(ds)
grd.DataSource = ds
grd.DataBind()
End Sub
End Class
all pages accessing .mdb files as database are throwing said error as my website is recently shifted to cloud it start giving errors on all pages. this error is from the server provider, as the code is working on my machine. but he is unable to resolve the same.
I have many instances of code where I am exporting a gridview to excel. This has been working fine until recently. I recently upgraded to Windows 10 (same version of excel), and have not been able to get this function to work for any of the pages where it is available. Excel opens, but no sheets. To confirm my suspicion, I tested on a Windows 7 machine and it worked fine. Is there a setting I am missing that got set during upgrade? The code for export is below.
Protected Sub ExportButton_Click(sender As Object, e As EventArgs) Handles ExportButton.Click
SqlDataSource1.SelectCommand = "SELECT * FROM [MyTable]..."
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim sw As New System.IO.StringWriter
Dim hw As New HtmlTextWriter(sw)
GridView1.Visible = True
GridView1.DataBind()
GridView1.RenderControl(hw)
Response.Write(sw.ToString)
Response.End()
GridView1.Visible = False
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Check if you are not expierence problems due to a Office Upate.
Seeexcel-2010-kb3115322-opening-downloaded-files
1) I have a windows service which will download documents. Now it is saving correctly to textfile.
2) Class library which have load function and save function
3) Website for viewing the files load and save to database.
For this In my windows service I have a reference to class library.
In my website I have reference to class library . But when I run my website "Exception of type 'System.OutOfMemoryException' was thrown" error is showing.
I am confused as the reference made is wrong or not.Help will be greatly appreciated.
Thanks
Code in Class library SerLib
Public Function SavetoDB()
dim X As String
Dim obj As clsMRec
Try
cmd =
New SqlCommand
cmd.Connection = con
For Each obj In clsMCollect_mails
cmd.CommandText =
"Insert into Master(From,,Subject) Values('" & mailRecObj.From & "',' " & mailRecObj.Sub & "',')"
cmd.ExecuteNonQuery()
Next
Catch ex As Exception
X = ex.Message()
End Try
End Function
End Class
In the website
Dim insMarec As New clsMaRec
' Dim c As p
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
insMarec.SavetoDB()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
insMarec.LoadfromServer()
End Sub
It seems there is not a problem with your reference
System.OutOfMemoryException' It is thrown by the .NET Framework execution engine. It can occur during any allocation call during runtime.
Example that raises out-of-memory exception: C#
class Program
{
static void Main()
{
// This program attempts to create a string of 2.1 billion characters.
// ... This results in an out-of-memory error.
// ... It would require 4.2 billion bytes (4 gigabytes).
string value = new string('a', int.MaxValue);
}
}
Output
Unhandled Exception: OutOfMemoryException.
Question
How much memory can be assumed?
No specific amount of memory in bytes can be counted on when executing a program. For most programs that do not allocate huge amounts of memory, this is not a serious problem.
However:
If you have a problem with this exception and the cause is not obvious, you can use MemoryFailPoint to help diagnose the issue.
So finally check again your code where you made any mistake like above example...
or Add some code in your qustion so we can understand batter ..
I'm currently trying to open a PDF file on my website that is located on my company's network. I had this working previously, but now for some reason it isn't working. Here is what I have:
I am using impersonation to access the file. It has domain admin privileges. This is from my web.config file (username/password are altered):
<identity impersonate="true" password="pass" userName="domain\user" />
I use this code to open the PDF in a window:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim strPath As String = CStr(Session("DWGPath"))
strPath = "file://san01/prodeng/" + Mid(strPath, 4)
strPath = Replace(strPath, "\", "/")
Dim pdfPath As String = strPath
Dim client As WebClient = New WebClient()
Dim buffer As Byte() = client.DownloadData(pdfPath)
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
Response.End()
Catch exa As WebException
Response.Redirect("DrawingError.aspx")
Catch ex As Exception
Throw ex
End Try
End Sub
This doesn't work. It redirects me to the "DrawingError.aspx" page. This link dispalys the "Session("DWGPath")" variable. I can take this variable and paste it in to my browser and the PDF opens without problem.
However, if I alter my code to this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim strPath As String = CStr(Session("DWGPath"))
Dim pdfPath As String = strPath
Dim client As WebClient = New WebClient()
Dim buffer As Byte() = client.DownloadData(pdfPath)
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
Response.End()
Catch exa As WebException
Response.Redirect("DrawingError.aspx")
Catch ex As Exception
Throw ex
End Try
End Sub
It still doesn't work.
The account also has full control privileges to the folder that contains the PDFs.
Any help or insight would be appreciated. Thank you!
EDIT: IF I throw exa then I get this:
The account used is a computer account. Use your global user account or local user account to access this server.
I assume you're running IIS. Go to the application pool for this app and change the identity that it's running under to be the domain\user account. See if that fixes your problem.
You want to make sure that the password on this account doesn't change or else it will fail when the password expires.
this is my code right now:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
System.Net.ServicePointManager.Expect100Continue = False
Dim client = New System.Net.WebClient()
Dim postdata = New System.Collections.Specialized.NameValueCollection
postdata.Add("username", "qweqwe")
postdata.Add("password", "asdasd")
Dim bytes = client.UploadValues("https://juzcode.com/post.php", postdata) ' exception here
Response.Write(Encoding.ASCII.GetString(bytes))
End Sub
However I'm getting exception "Unable to connect to the remote server". Am I doing something wrong?
Btw this is the code for http://juzcode.com/post.php:
<?php if($_POST["username"]==="qweqwe" && $_POST["password"]==="asdasd")echo "<b>success</b>";else echo "<i>failed</i>";
Here is an example on the web of using c# to post to PHP:
http://blog.brezovsky.net/en-text-1.html
Put your code into a Try / Catch you may be trying to fight a loosing battle behind a corporate firewall.
Check the exception.