|
|
Hello;
I have trouble with SQL Server 7.0 API. I'm getting following error at link phase. Source code at below; (VC++ 6)
// SmcDatabase.cpp: implementation of the CSmcDatabase class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "smc_client.h"
#include "SmcDatabase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#define MAXBUFLEN 255
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <odbcss.h>
#include <afxpriv.h>
#include <afxdisp.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSmcDatabase::CSmcDatabase()
{
}
CSmcDatabase::~CSmcDatabase()
{
}
HRESULT CSmcDatabase::Connect(char* server, char* uid, char* pwd)
{
SQLHENV henv = SQL_NULL_HENV;
SQLHDBC hdbc1 = SQL_NULL_HDBC;
RETCODE retcode = 0;
// This format of the SAVEFILE keyword saves a successful
// connection as the file Myfiledsn.dsn in the ODBC default
// directory for file DSNs.
SQLCHAR szConnStrIn[MAXBUFLEN] =
"SAVEFILE=MyFileDSN;DRIVER={SQL Server};SERVER=MySQL;"
"NETWORK=dbmssocn;UID=sa;PWD=MyPassWord;";
SQLCHAR szConnStrOut[MAXBUFLEN];
SQLSMALLINT cbConnStrOut = 0;
// Allocate the ODBC Environment and save handle.
retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv);
// Let ODBC know this is an ODBC 3.0 application.
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
// Allocate an ODBC connection handle and connect.
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
retcode = SQLDriverConnect(hdbc1, // Connection handle
NULL, // Window handle
szConnStrIn, // Input connect string
SQL_NTS, // Null-terminated string
szConnStrOut, // Addr of output buffer
MAXBUFLEN, // Size of output buffer
&cbConnStrOut, // Address of output length
SQL_DRIVER_NOPROMPT);
return(retcode);
}
Error message;
--------------------Configuration: smc_client - Win32 Debug--------------------
Linking...
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLDriverConnect@32
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLSetEnvAttr@16
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLAllocHandle@12
Debug/smc_client.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
smc_client.exe - 4 error(s), 0 warning(s)
Thank you for helps...
|
|
|
|
|
Sounds you're not linking odbc32.lib.
Don't know right now how to add it exactly (in .NET -> project properties, Linker, Input, Additional Dependencies)
Succes!
|
|
|
|
|
Thank you.
Ahmet Orkun GEDiK
|
|
|
|
|
Hi all, I need a second opinion on this. Recently I've been struggling with trying to load user controls dynamically. Simple right. Well not if those user controls also host other user controls that are loaded dynamically. It's technically possible but all solutions I've seen so far haven't worked and they have been hacks. The main problem with loading user controls dynamically is keeping track of view state and wiring up events.
Now, one workaround I thought of was loading all the user controls at compile time (so that they are actually part of the page) and hiding/showing the desired controls depending on user input. I had thought that the resultant html source produced would end up becoming bloated with hidden controls. A quick test however, showed that the source ends up excluding all invisible controls, ie they are simply not rendered. So the resultant page is NOT bloated.
To prevent too much work being done on the server however, I thought you could test to see if the control was visible in which case you could safely call your data binding code for example, and if not, you simply do nothing when the control loads.
Well, what do you guys think? Is this how you do it as well? I'd like to hear pros and cons.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Why in the HELL does WebForm designer restructure my nicely formated code in to a bunch of table tags?!?!
Original Code:
<DIV style="WIDTH: 873px; POSITION: relative; HEIGHT: 320px" ms_positioning="GridLayout">
<asp:button id="cmdUpdate" style="Z-INDEX: 101; LEFT: 584px; POSITION: absolute; TOP: 264px" tabIndex="10" runat="server" Width="80px" Height="24px" Text="Update"></asp:button>
<asp:label id="Label8" style="Z-INDEX: 102; LEFT: 400px; POSITION: absolute; TOP: 16px" runat="server" Width="136px">Welcome Message:</asp:label>
etc...
After changing just ONE item in the designer:
<DIV ms_positioning="GridLayout">
<TABLE height="320" cellSpacing="0" cellPadding="0" width="873" border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="0" height="1"></TD>
<TD width="8"></TD>
<TD width="8"></TD>
<TD width="168"></TD>
<TD width="88"></TD>
<TD width="16"></TD>
<TD width="112"></TD>
<TD width="184"></TD>
<TD width="88"></TD>
<TD width="201"></TD>
</TR>
<TR vAlign="top">
<TD width="0" height="15"></TD>
<TD colSpan="3" rowSpan="2">
<input id="hdnID" type="hidden" runat="server" NAME="hdnID"></TD>
<TD colSpan="8"></TD>
</TR>
<TR vAlign="top">
<TD width="0" height="24"></TD>
<TD rowSpan="10"></TD>
<TD colSpan="2">
<asp:label id="Label1" runat="server" Width="152px" Height="16px">Client Name:</asp:label></TD>
etc...
This makes no sense to me, and is EXTREMELY frustrating, because when I go back to the designer, everything is completely misplaced.
Thanks in advance for any ideas.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
Hmmm, I've never experienced that.But I always use a simple HtmlTable for layout. If push comes to shove, you can try that instead.
Senkwe
Just another wannabe code junky
|
|
|
|
|
Thanks, Senkwe. Actually, I figured it out last night. Turns out that I'd somehow set my WebForm to target Internet Explorer 3.0 or below, and since those browsers don't support controls being layed on top of one another, it wraps them in table tags. None of my controls were overlapping, so I guess the designer was just playing it safe.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
I want to display a value as hours which is stored as seconds in a database so I need to convert the value when I bind it to a textbox control. Something like this:
<asp:textbox id="hours" size="3" text='<%# DataBinder.Eval(Container.DataItem, "interval") / 3600 %>' runat="server" />
On the submit side it's easy enough to convert it back to seconds but I'm not sure how to convert it on the aspx side. I can probably change the sql statement but I would like to avoid that. I would also like to avoid having to do the conversion in the page_load function. Can this be done?
Todd Smith
|
|
|
|
|
The method I've used for this type of problem is to create a public method that formats the required output
<asp:textbox id="hours" size="3" text='<%# MyFunction(DataBinder.Eval(Container.DataItem, "interval", "{0}") )%>' runat="server" />
public string MyFunction(string strSeconds)
{
return int.Parse(strSeconds) / 3600;
}
|
|
|
|
|
That works. thx.
<asp:textbox id="hours" size="3" text='<%# Utils.SecsToHours(DataBinder.Eval(Container.DataItem, "hours").ToString()) %>' runat="server" />
public static string SecsToHours(string seconds)
{
try
{
int secs = Int32.Parse(seconds);
int hours = secs / 3600;
return hours.ToString();
}
catch
{
return "";
}
}
Todd Smith
|
|
|
|
|
HI,
IIS is being a twat. It won't let users download .exes from my web site. They user gets a 404 when the input the URL when I know for a fact that the files are there. Could it be some sort of security 'feature' that is causing this? I have run the IIS lockdown tool in the past - is it possible that this has affected it?
By the way, HTML, ASP, JPG, GIF all work fine.
Cheers
|
|
|
|
|
For anyone that cares, I think this is due to IIS lockdown as it restricts the downloading fo some filetypes. I'l know better when I get home tonight and try it out.
|
|
|
|
|
Try setting the Application Settings (Home Directory) the Execute Permissions on None (or Scripts only).
Next check HTTP Headers, File Types for the Registered file type .exe (this must be application/octet-stream).
Succes!
|
|
|
|
|
Thanks for the response but it was the URLScan component of IIS Lockdown wheich was restricting the downloading of exes. God know why
|
|
|
|
|
URLScan blocks exes because they might run on the server, depending on the configuration. You can comment out the exe extension in the DenyExtensions section of the urlscan.ini file [%systemroot%\system32\inetsrv\urlscan\urlscan.ini ], or create an asp page to handle the request and Response.BinaryWrite the file.
|
|
|
|
|
Hi All
I have a data populated in HTML table (3 columns, mutiplerows), I have a text box in the col1,row1. when I press Tab button the focus goes to col2,row1 then col3,row1...what I need is how to make the tabing goes from col1,row1 to col1,row2???????
Thanks in advance
|
|
|
|
|
If you set the tabindex property of the text boxes you can control the tab flow.
|
|
|
|
|
Is there a way to import Excel-files with ASP and can you put the data into a database (like MsSQL)
Thanks!!!
Morten
|
|
|
|
|
Yes, you can use ADO to read from the Excel file, or just the Excel COM objects if it is installed.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Hi,
Here's what I'm trying to do:
I have a local application which stores data (locally) in an access or SQLServer database. What I need to do is pass a subset of that data to a remote database on the internet. There are a couple of provisos though - can only use c++/WIN32 on the client (no MFC or .Net), can use any damn technology on the server.
Here are a few methods I have considered:-
1) Convert to XML locally, upload to server using FTP, parse using XML control from ASP page and write into DB. (bit cludgy)
2) Convert to XML string , write to ASP page as HTTP POST and parse in ASP page.
3) Use some crazy new .NET technology (on the server only) to accomplish this for me?
The amount of data transmitted is likely to be pretty small (~10K).
Anybody have any thoughts/suggestions??
Cheers
|
|
|
|
|
Use SQLXML on the server.
|
|
|
|
|
Does this allow you to insert into the remote DB. I've had a quick look on MSDN and it looks like it can be used to query remote data sources but I need to insert. I also need the client to work without any special software (like SOAP or .NET).
Can you point me at any links or other info?
Cheers
|
|
|
|
|
Not sure if this will help you but it could be a start
|
|
|
|
|
James Spibey wrote:
I have a local application which stores data (locally) in an access or SQLServer database.
Which one? If you have SQL Server as your source you could create a DTS package to grab information and push it out to another source.
Nick Parker
|
|
|
|