TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Newbie Xamarin
NA
15
3.6k
Xamarin - Android Connect to SQL Server via WIFI
Apr 28 2020 11:56 AM
Hi everybody,
I am a newbie to XAMARIN and working in XAMARIN (VS-2019) on a sample android app to connect to an SQL Server 2014 database to perform CRUD actions using direct ADO SqlClient connection, and did all required remote connection configurations on my server such as: Enabling TCP/IP - Setting Exception rules on the Firewall (1433 for TCP and 1434 for UDP - Program Exception for SQL Server, and Program exception for SQL Browser), so all fine.
Actually my application seemed to be working on the emulator on debug, but not when published on a real android device, my application just ignores my request and goes back to the Main activity.
Could someone help me out please so this is my code:
public
void
InsertUser()
{
try
{
// Connect using Server IP Adress instead of Server Name
string
dbstring = @
"data source=xxx.xx.xx.xx,1433;initial catalog=MyDatabase;user id=XamarinUser;password=myPassword;Connect Timeout=10"
;
SqlConnection Con =
new
SqlConnection(dbstring);
if
(Con.State == ConnectionState.Open) { Con.Close(); }
Con.Open();
SqlCommand cmd =
new
SqlCommand(
"INSERT INTO tblUSERS (Username, Password, Email, Active) VALUES ('"
+ txtUserName.Text +
"','"
+ password1.Text +
"','"
+ txtEmail.Text +
"',0);"
, Con);
cmd.ExecuteNonQuery();
Con.Close();
Con =
null
;
cmd =
null
;
this
.Dismiss();
}
catch
(Exception)
{
throw
new
Exception(
"Application run into errors. Please contact us."
);
}
}
And thanks for your help.
Reply
Answers (
0
)
Document management system file type C#
Cell content double click not working Properly?