Vegas
Vegas
CC#
Created by Vegas on 8/6/2024 in #help
Loop For X times
Im tring to get X amount of boxes to fill depending on random number. Im only getting 1
c#
int count = 0;

Random rdmamt = new Random();
int amount = rdmamt.Next(0,8);
int x = rdmamt.Next(0, 16);
int y = rdmamt.Next(0, 13);

if (count <= amount)
{
for (int i = 0; i < amount; i++)
{
Playarea.Add(new BoxView()
{
Color = Colors.DarkGray,
}, x, y);
}
}
c#
int count = 0;

Random rdmamt = new Random();
int amount = rdmamt.Next(0,8);
int x = rdmamt.Next(0, 16);
int y = rdmamt.Next(0, 13);

if (count <= amount)
{
for (int i = 0; i < amount; i++)
{
Playarea.Add(new BoxView()
{
Color = Colors.DarkGray,
}, x, y);
}
}
Thanks
15 replies
CC#
Created by Vegas on 7/25/2024 in #help
maui Datagrid From ( akgul.Maui.DataGrid )
No description
3 replies
CC#
Created by Vegas on 7/13/2024 in #help
DataGrid Cell Selection / Row Color
No description
8 replies
CC#
Created by Vegas on 7/9/2024 in #help
VS 2022 - Root Element is not valid - WPF
No description
12 replies
CC#
Created by Vegas on 7/3/2024 in #help
WPF - Using RTF as a Notes section.
No description
1 replies
CC#
Created by Vegas on 6/28/2024 in #help
new command fixing memory leak.
So i have been able to fix memory leak on Windows and forms but cant figure out how todo it with pages. So i am calling specific pages to show inside a frame on button press. Upon changing pages you end up keeping the memory used instead of clearing the data.
private void btn_home_Click(object sender, RoutedEventArgs e)
{
workarea.Content = new Store_My_Client.Pages.Page1();
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
workarea.Content = new Store_My_Client.Pages.Page2();
}
private void btn_home_Click(object sender, RoutedEventArgs e)
{
workarea.Content = new Store_My_Client.Pages.Page1();
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
workarea.Content = new Store_My_Client.Pages.Page2();
}
Any ideas? Thanks
7 replies
CC#
Created by Vegas on 6/21/2024 in #help
Connecting to database via String in XML
So i have done searching after searching and i keep getting stuck on having the connection error as a string.
<connectionStrings>
<clear />
<add name="Test"
providerName="localhost"
connectionString="Data Source=DESKTOP-6L5A1E6;Integrated Security=True;Connect Timeout=30;Encrypt=True;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False" />
</connectionStrings>
<connectionStrings>
<clear />
<add name="Test"
providerName="localhost"
connectionString="Data Source=DESKTOP-6L5A1E6;Integrated Security=True;Connect Timeout=30;Encrypt=True;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False" />
</connectionStrings>
private SqlConnection cont;

static class Program
{
static void Main()
{
GetConnectionStrings();
Console.ReadLine();
}

static void GetConnectionStrings()
{
ConnectionStringSettingsCollection settings = ConfigurationManager.ConnectionStrings;

foreach (ConnectionStringSettings cs in settings)
{
Console.WriteLine(cs.Name);
Console.WriteLine(cs.ProviderName);
Console.WriteLine(cs.ConnectionString);
}
}
}
private SqlConnection cont;

static class Program
{
static void Main()
{
GetConnectionStrings();
Console.ReadLine();
}

static void GetConnectionStrings()
{
ConnectionStringSettingsCollection settings = ConfigurationManager.ConnectionStrings;

foreach (ConnectionStringSettings cs in settings)
{
Console.WriteLine(cs.Name);
Console.WriteLine(cs.ProviderName);
Console.WriteLine(cs.ConnectionString);
}
}
}
private void button1_Click(object sender, EventArgs e)
{

var Connect = ConfigurationManager.ConnectionStrings["Test"];
var qury = "SELECT * FROM users WHERE Username = @username and password=@password";
string returnValue = "";
using (SqlConnection conn = new SqlConnection(**Connect**))
{
using (SqlCommand sqlcmd = new SqlCommand(qury, conn))
{
sqlcmd.Parameters.Add("@username", SqlDbType.VarChar).Value = textBox1.Text;
sqlcmd.Parameters.Add("@password", SqlDbType.VarChar).Value = textBox2.Text;
conn.Open();
returnValue = (string)sqlcmd.ExecuteScalar();
}
}

}
private void button1_Click(object sender, EventArgs e)
{

var Connect = ConfigurationManager.ConnectionStrings["Test"];
var qury = "SELECT * FROM users WHERE Username = @username and password=@password";
string returnValue = "";
using (SqlConnection conn = new SqlConnection(**Connect**))
{
using (SqlCommand sqlcmd = new SqlCommand(qury, conn))
{
sqlcmd.Parameters.Add("@username", SqlDbType.VarChar).Value = textBox1.Text;
sqlcmd.Parameters.Add("@password", SqlDbType.VarChar).Value = textBox2.Text;
conn.Open();
returnValue = (string)sqlcmd.ExecuteScalar();
}
}

}
Creating the new Connection is throwing error cannot convert from 'System.Configuration.ConnectionStringSettings' to 'string' Thanks
55 replies