Showing posts with label avoid. Show all posts
Showing posts with label avoid. Show all posts

Friday, March 23, 2012

Replace ODBC Login Prompt in MS Access

I'm controlling the connections to my SQL Server through code. I'm trying to avoid saving the username and password in code however. It's easy for me to display my own login form, accept a username and password, and use those to reconnect my linked tables. However, I'm trying to figure out how to work around the problem of when a user enters an improper username and password. The system would then bring up the standard ODBC username and password dialog. I want to trap this, not display it and return to my form.
I've been told elsewhere that it's possible to tell the ODBC dll to silently fail back to Access or some such thing.
-David

Just for the clarification: how do you use ODBC in MS Access? Do you use ADO or do you do something else?

|||Hi,

you can use the SQL_DRIVER_NOPROMPT which tells the driver not to prompt for a login box. More information about that can be found here:

http://msdn2.microsoft.com/en-us/library/ms131326.aspx

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

Wednesday, March 21, 2012

Replace chars in any field of a table

I need to strip some puntcuation from any field in a given table.
I'd rather like to avoid using the replace () for each field in the
table.
Anyone have a nifty way do this?
Is there a special name that I can use in the replace that means the
entire row?
(other than syntax, something like REPLACE(@.ROW,CHAR(39),'') )
tia
RobYou could try the following. It uses a cursor, which I'm sure is a bad
thing. But it should work. I didn't try it out. The cursor grabs
column names for columns that are of a varchar type. That may not be
what you need. But the Replace function requires a string, so there ya
go. Maybe (most likely) someone will have a better way to do this.
Hope it helps.

Jennifer

Declare @.Tbl nvarchar(100)
Declare @.Qry nvarchar(1000)
Declare @.N nvarchar(100)

Set @.Tbl = 'TableName'

DECLARE col_cursor CURSOR FOR
select name
from syscolumns
where id = object_id(@.Tbl)
and xtype = 167
order by colid

OPEN col_cursor
FETCH NEXT FROM col_cursor into @.N

WHILE @.@.FETCH_STATUS = 0
BEGIN
Set @.Qry = 'Update ' + @.Tbl + ' Set ' + @.N + ' = REPLACE (' + @.N +
', ''-'' , '''')'
EXEC sp_executesql @.Qry
FETCH NEXT FROM col_cursor into @.N
END

CLOSE col_cursor
DEALLOCATE col_cursor